I'm trying to compile a C/C++ program that uses SDL on a OS X 10.6.8 but I'm having some errors on the linking stage, the code compiles but fails to like due to some missing symbols. The error is:
Undefined symbols for architecture x86_64:
"_CFBundleGetMainBundle", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
_main in libSDLmain.a(SDLMain.o)
"_CFBundleCopyBundleURL", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLCreateCopyDeletingLastPathComponent", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFURLGetFileSystemRepresentation", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
"_CFRelease", referenced from:
-[SDLMain setupWorkingDirectory:] in libSDLmain.a(SDLMain.o)
...
"_OBJC_CLASS_$_NSAutoreleasePool", referenced from:
objc-class-ref in libSDLmain.a(SDLMain.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [dist/linwarrior] Error 1
I checked with the file command and the libraries are either x86_64 only or universal with both i386 and x86_64 versions.
Is there a way for me to determine what exactly is causing this error? A way to check the libs that are being included or any way to help debug the problem?
I don't know if it helps but this is what my Makefile creates, I removed file names to make it short, and the KNT flag is just something I'm using for preprocessor conditions:
/opt/local/bin/g++-mp-4.5 -DKNT=1 -Wp,-M,-MP,-MT,-MF, -std=c++0x -Wall -I source -O1 -funroll-loops -c -o
Thanks.
Related
spent some time, with the big help of other SO user, trying to install Allegro library on osx 10.10.5
Finally it seems like it is ok, so I open the code blocks, pasted the example code( http://partitionseven.blogspot.com/2011/01/compiling-allegro-5-with-mac-os-x-snow.html), and I get an error while copiling
g++ -c /Users/lukasz/Desktop/test_allegro/test.cpp -o /Users/lukasz/Desktop/test_allegro/test.o
g++ -o /Users/lukasz/Desktop/test_allegro/test /Users/lukasz/Desktop/test_allegro/test.o
Undefined symbols for architecture x86_64:
"_al_clear_to_color", referenced from:
__al_mangled_main in test.o
"_al_create_display", referenced from:
__al_mangled_main in test.o
"_al_destroy_display", referenced from:
__al_mangled_main in test.o
"_al_flip_display", referenced from:
__al_mangled_main in test.o
"_al_install_system", referenced from:
__al_mangled_main in test.o
"_al_map_rgb", referenced from:
__al_mangled_main in test.o
"_al_rest", referenced from:
__al_mangled_main in test.o
"_main", referenced from:
implicit entry/start for main executable
(maybe you meant: __al_mangled_main)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
when I follow the tutorial exactly running the code from terminal with
gcc alleg5test.c -o alleg5test -L/usr/local/lib -lallegro -lallegro_main
./alleg5test
it works- i got a black screen. But how do I make it work from Code Blocks?
The following is returned when trying to compile part of a project under OSX:
gcc -g -pipe -L/Projects/export buf_test.o buf.o -framework CoreFoundation -o buf_test
Undefined symbols for architecture x86_64:
"___assert_rtn", referenced from:
_init in buf.o
_get in buf.o
_put in buf.o
"___sprintf_chk", referenced from:
_test in buf_test.o
"___strcpy_chk", referenced from:
_test_data_copy in buf_test.o
___inline_strcpy_chk in buf_test.o
"_exit", referenced from:
start in crt1.10.6.o
"_printf", referenced from:
_test in buf_test.o
"_puts", referenced from:
_test in buf_test.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
Help would be much appreciated!
Turns out it was a library naming conflict with the standard libraries -- I had a library called libSystem.a in /Projects/export which was masking libSystem.dylib from being found.
when I try to compile and run the gmp-chudnovsky.c file found here with xcode the following errors appear:
Undefined symbols for architecture x86_64:
"_fac_clear", referenced from:
_main in main.o
"_fac_compact", referenced from:
_fac_remove_gcd in main.o
"_fac_init", referenced from:
_main in main.o
"_fac_mul", referenced from:
_bs in main.o
"_fac_mul_bp", referenced from:
_bs in main.o
"_fac_resize", referenced from:
_fac_remove_gcd in main.o
"_fac_set_bp", referenced from:
_bs in main.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I know the gmp library is installed correctly as I have another xcode project linking to it that is compiling correctly. Any ideas as to why this is happening?
Forgot to say I have added paths to the header file and library for GMP as well as add the -lgmp flag under Other Linker Flags
SOLVED: see this answer.
I think xcode runs in a Debug configuration first, where no optimization is performed and no inlining is carried out. This means any inline function must also be made static.
I am trying to test out a few simple Cairo programs, but I am having trouble figuring how to include the source files. I have installed the Cairo library - it's just a question of how to let gcc know...
I have the .h files (including cairo.h) installed in /usr/local/include/cairo
I have the .dylib files installed in /usr/local/lib and /usr/local/lib/cairo
Are there any other components of the installation I should be aware of? (I just did 'make install' to install the library)
I am trying to compile like this:
$ gcc cairoTest.c -I/usr/local/include/cairo -L/usr/local/lib/
My cairoTest.c file starts out with:
include <cairo.h>
gcc is finding cairo.h, but it gives the following error message. I think it is not linking to the .dylib files correctly, but I'm not sure. I'm still new to compiling/linking.
gcc cairoTest.c -I/usr/local/include/cairo -L/usr/local/lib/cairo
Undefined symbols for architecture x86_64:
"_cairo_image_surface_create", referenced from:
_main in ccVd9Pet.o
"_cairo_create", referenced from:
_main in ccVd9Pet.o
"_cairo_scale", referenced from:
_main in ccVd9Pet.o
"_cairo_set_line_width", referenced from:
_main in ccVd9Pet.o
"_cairo_set_source_rgb", referenced from:
_main in ccVd9Pet.o
"_cairo_rectangle", referenced from:
_main in ccVd9Pet.o
"_cairo_stroke", referenced from:
_main in ccVd9Pet.o
"_cairo_surface_write_to_png", referenced from:
_main in ccVd9Pet.o
"_cairo_destroy", referenced from:
_main in ccVd9Pet.o
"_cairo_surface_destroy", referenced from:
_main in ccVd9Pet.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [all] Error 1
What should I be doing differently to include the Cairo library in my compilation?
Thanks,
Try to compile with
gcc -Wall -g cairoTest.c -I/usr/local/include/cairo -L/usr/local/lib/ -lcairo -o cairoTest
(but you probably need other libraries, perhaps thru $(pkg-config --cflags --libs cairo) or similar)
And your file should start with
#include <cairo.h>
I'm trying to compile basic plugin for firefox and linker reports following problem:
Undefined symbols for architecture i386:
"_NPN_GetValue", referenced from:
_PluginLog in main.o
"_NPN_GetStringIdentifier", referenced from:
_PluginLog in main.o
"_NPN_GetProperty", referenced from:
_PluginLog in main.o
"_NPN_Invoke", referenced from:
_PluginLog in main.o
"_NPN_ReleaseObject", referenced from:
_PluginLog in main.o
"_NPN_ReleaseVariantValue", referenced from:
_PluginLog in main.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
have I missed to add some linked libraries?
You can't just call those functions like you would a normal function (they aren't exported by a browser, nor are you linking against a browser); you need to use the function pointers from the NPNetscapeFuncs struct passed to you by the browser.