"XXX", referenced from: XXX constin libXXX.a (XXX.o) problem using C++ and C mixed with Objective C++ for Iphone library/game
I'm developing an static library for PC/Iphone.
Library is called libNerv.lib / libNERV.a
The Project is written in C++ (+Objective C++ for iphone)
Until now everything worked fine for pc and iphone. The game app uses the library and links it fine. but now I have to use libpng for the project. I want to share one library so I included the .c file from libpng into my library project. On windows everything works fine! The game can link against my library without problems.
Today I moved on to Iphone added the libpng files to the iphone project and the library builds fine. Soon as I build the game app the linker fails with following messages:
"_png_read_image", referenced from:
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
"_png_create_read_struct", referenced from:
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
"_png_read_end", referenced from:
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
"_png_destroy_read_struct", referenced from:
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
"_png_read_info", referenced from:
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
"_png_read_update_info", referenced from:
NERV::Video::LoadPNG::loadImage(NERV::IO::IFileReader*) constin libNERV.a(LoadPNG.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
This is a problem because it simply ignors all my tries. (NOTE, it woks with VS 2008 on pc!!) I have tried several things to get rid of the linker errors:
I have tried to change all libpng files from .c to cpp which worked quite well, I had just to resolve 2 typecast errors (void* to char*), but I had still the same errors. I have tried to create a own library for he libpng files. But it didn't work either.
I tried to open my libNerv.a with ar, libtool, ranlib without any success (just told me it is created with fat... or something)
libpng files use extern C declarations for cpp projects so I don't know if it is good to compile it with cpp. Maybe someone knows more on that too.
There is on thing I haven't tried yet. I will add the libpng files to the game app and compile it with the app but I don't think this will work.
(Note: all reference problems are in the same method, and I don't use libpng anywhere else - this method is in libNerv.a which builds without problems. The problems only occur one the libNerv.a gets l开发者_运维问答inked with the iphone app!)
I hope someone can help me with this issue :)
Did you add the resulting libpng.a
(or something like that) as one of the libraries linked to the main executable?
You successfully built libNERV.a
which means you added libpng.a
in the list of libraries used to make libNERV.a
.
But you need to specify libpng.a
in the linker setting for the main executable, too.
精彩评论