Problems with SDL image - c++

I'm running on a mac OS 10.8.2 and compiling my program with the following command;
g++ main.cpp `sdl-config --cflags --libs` -o whateverfilename
I can compile SDL programs just fine but as soon as I try to use the SDL image library, things go wrong - I get the following errors:
Undefined symbols for architecture x86_64:
"_IMG_Init", referenced from:
_SDL_main in cco8lzYA.o
"_IMG_Load_RW", referenced from:
_SDL_main in cco8lzYA.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I'm guessing the linker is missing a search path or something. I've been trying to look up and edit the linker search paths but can't seem to manage even that so if someone could tell me how to do that or what other problems I might be causing I'd appreciate it :)

I think you need to add the lSDL_Image compiler flag, I'm very much a noob when it comes to C++ and SDL, it was ages since I've done anything with it.
I also very much recommend LazyFoo's tutorials

Related

Error when compile umfpack after the update of Mac

I was able to use umfpack, but I just found that I cannot use it as before. I guess the reason is my recent update of Mac.
I already installed SuiteSparse VERSION 4.5.4. I use the Fortran interface, umfpack.f90, from http://geo.mff.cuni.cz/~lh/Fortran/UMFPACK/. And use gfortran umfpack.f90 umfpack_simple_3subr.f90 -L/usr/local/lib -lumfpack to compile. But I got the following errors:
Undefined symbols for architecture x86_64:
"__gfortran_os_error_at", referenced from:
___mumfpack_MOD_umfpack_zi_operator_pcsr in ccAIP7gL.o
___mumfpack_MOD_umfpack_zi_operator_pcsc in ccAIP7gL.o
___mumfpack_MOD_umfpack_zi_operator_csr in ccAIP7gL.o
___mumfpack_MOD_umfpack_zi_operator_csc in ccAIP7gL.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I have no clue about solving the problem. Any suggestion is appreciated! Thank you in advance!

Error when compiling with mpifort

I have downloaded OpenMPI, but after trying to run a simple parallelized Hello world program I get the following error:
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I guess there is a problem with the compiler because I struggled quite a lot to install OpenMPI.
In order to get that error I typed from the terminal:
mpifort -o hello.f90
Someone can help me?

Issue compiling Go program when linking to a compiled version of zeromq on Mac

I've compiled ZeroMQ on Mac OSX 10.9.5 in order to then link to a simple Go program using github.com/pebbe/zmq4, but I'm getting this error I don't understand or know exactly how to remedy.
# github.com/pebbe/zmq4
ld: warning: ignoring file /usr/local/lib/libzmq.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libzmq.dylib
Undefined symbols for architecture i386:
"_zmq_bind", referenced from:
__cgo_59814aec404b_C2func_zmq_bind in zmq4.cgo2.o
__cgo_59814aec404b_Cfunc_zmq_bind in zmq4.cgo2.o
(maybe you meant: __cgo_59814aec404b_Cfunc_zmq_bind, __cgo_59814aec404b_C2func_zmq_bind )
"_zmq_close", referenced from:
__cgo_59814aec404b_C2func_zmq_close in zmq4.cgo2.o
__cgo_59814aec404b_Cfunc_zmq_close in zmq4.cgo2.o
(maybe you meant: __cgo_59814aec404b_C2func_zmq_close,
...
"_zmq_z85_encode", referenced from:
__cgo_59814aec404b_Cfunc_zmq_z85_encode in zmq4.cgo2.o
(maybe you meant: __cgo_59814aec404b_Cfunc_zmq_z85_encode)
ld: symbol(s) not found for architecture i386
collect2: error: ld returned 1 exit status
I think it makes sense that the dylib is made for x86_64 (the Mac) but why Go is trying to link with i386? How do I control that and make it link differently? or even if it's correct?
If you build libzmq yourself, configure with --disable-shared --enable-static keys. If you use homebrew, uninstall zmq and build the library manually. If you need "fat" universal static library use this script:
https://github.com/drewcrawford/libzmq-ios

OSX Disk Arbitration linker errors

Trying to compile my C++ application using clang which works but I get the following linker error:
Undefined symbols for architecture x86_64:
"_DADiskCopyDescription", referenced from:
Security::getHddID() in Security.cpp.o
"_DADiskCreateFromBSDName", referenced from:
Security::getHddID() in Security.cpp.o
"_DASessionCreate", referenced from:
Security::getHddID() in Security.cpp.o
ld: symbol(s) not found for architecture x86_64
I've checked the official documentation for Disk Arbitration on the Apple website but that's awful, since it doesn't even tell you which library file to include, let alone what to link to.
I'm using CMake to set up my build chain.
You need to use -framework DiskArbitration in your linker arguments.

Lear Gist Descriptor C code used with C++

I am using Lear's implementation of the Gist descriptor for a project which can be found here: http://lear.inrialpes.fr/software.
I am writing an application in c++ and I want to use this library. I am having issues though with the makefile and linking in general.
These commands give me no errors:
g++ -c standalone_image.c -o standalone_image.o
g++ -c gist.c -o gist.o
However, this line
g++ compute_gist.c `pkg-config --cflags --libs opencv`
gives me the following error
Undefined symbols for architecture x86_64:
"color_gist_scaletab(color_image_t*, int, int, int const*)", referenced from:
_main in ccMFYbAU.o
"color_image_delete(color_image_t*)", referenced from:
_main in ccMFYbAU.o
"color_image_new(int, int)", referenced from:
load_ppm(char const*)in ccMFYbAU.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
I have the Mosaic c++ code in a different directory. I also tried to compile gist and standalone_image seperately, copy into the mosaic directory, and compile the Mosaic code.
Which gives me the following error:
Undefined symbols for architecture x86_64:
"color_gist_scaletab(color_image_t*, int, int, int const*)", referenced from:
_main in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [mosaic] Error 1
I really want to use this library in my project, but I can't figure out a way to incorporate it in my c++.
Any help is GREATLY appreciated! Thanks!
Edit: I am using Mac Lion with:
gcc + g++ version: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
The lear library also uses the FFTW3 library that should work with C and C++.
The problem was that I needed the extern around the gist include, but the linking that was done in the Makefile was also wrong. It works now. :)