I'm working with FFMPEG on Mac OSX, my Mac version is 10.6.8 (i386).
When I try to compile my C++ code linking a dynamic library:
g++ sdk.cpp -rpath /usr/local/lib/libinsight.dylib -o sdk
I get the following error:
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
"av_open_input_file(AVFormatContext**, char const*, AVInputFormat*, int, AVFormatParameters*)", referenced from:
ffmpeg_open(AVFormatContext**, char const*, int*)in ccCkx9dd.o
(so forth fo every FFMPEG call)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Without linking dylib I have no problem. What's the matter?
P.S. ffmpeg version is Mach-O 64-bit executable x86_64
g++ sdk.cpp -rpath /usr/local/lib/libinsight.dylib -o sdk
Shouldn't you be linking to libffmpeg somewhere? Try adding -lffmpeg to your link command line.
Related
Given a very simple fortran (95) function and a very simple c++ call to the program, I should be able to compile the program using:
g++ -c main1.cpp
gfortran -c test.f95
g++ main1.o test.o -o run
However, here I get the following error:
ld: warning: object file (test.o) was built for newer macOS version (11.5) than being linked (11.0)
Undefined symbols for architecture arm64:
"hello_()", referenced from:
_main in main1.o
"__gfortran_st_write", referenced from:
_hello_ in test.o
"__gfortran_st_write_done", referenced from:
_hello_ in test.o
"__gfortran_transfer_character_write", referenced from:
hello in test.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Here, adding a -v tag before the -o tag and after the -o tag and the exe run did not solve the problem, as suggested by the error message.
So I'm trying to run a .s file and every time I do using the command line:
gcc -m32 -o Compute32 Compute.s
I'm given this error:
Undefined symbols for architecture i386:
"_main", referenced from:
implicit entry/start for main executable
"printf", referenced from:
main in Compute-f6f555.o
"scanf", referenced from:
main in Compute-f6f555.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation
Can anyone advise me on the next step?
I can only guess since you didn't show me your Compute.s, but I guess your problem is that on OS X, all C functions are prefixed with an underscore in assembly. So if you change your main to _main and likewise printf to _printf, etc. your problem should be resolved.
I am trying to compile dynamic lib in Mac OS X Mavericks, but when I try to link it, it says:
Undefined symbols for architecture i386:
"operator new(unsigned long, int, char const*, int)", referenced from:
...
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Compile flags I use:
Wall -Wextra -m32 -march=pentium4 -arch i386 -fvisibility=hidden
tried with
-stdlib=libc++ -lstdc++ -lc++
not helping.
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
Please help!
EDIT:
Ok, lack of attention:
ld: symbol(s) not found for architecture i386
So, figured out that this is only happening when -g flag is present :)
For release build there is no error.
The question that arises is why there is no debug information symbols on MacOS X for libc++ (operator new). Any clues?
I got nasm and I want to compile assembly into an executable. I keep getting the error:
ld: warning: ignoring file firststart.asm, file was built for unsupported file format which is not the architecture being linked (x86_64)
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
when I try to compile with gcc. I am using gcc that comes with xcode. What am I doing wrong?
Have anyone used to do with Awesomium framework on Mac OSX? I try to create a sample project and add code in main.m, but it has error
Undefined symbols for architecture i386:
"Awesomium::WebCoreConfig::setCustomCSS(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Do you have any ideas for this error?
main.m is an Objective-C source file and std::__1::basic_string, std::__1::allocator > const& is a C++ class.
Change the name of main.m to main.mm, making it a Objective-C++ source file and try again.
Awesomium is 32 bit only (a current limitation of chromium) while Apple's compiler defaults to 64 bits these days.
You have to compile your app using -m32 (or if using Xcode setting the architecture to 32 bit only as in the link the OP posted)
Example:
clang -m32 awe_test.cpp -o test -framework Awesomium -F$(DIR_WHERE_I_HAVE_AWESOMIUM) -I$(DIR_WHERE_I_HAVE_AWESOMIUM)