Linux server, build works but install fails..

Added by AlexS over 7 years ago

Hey all i was working at including a custom .lib file and the header to access it. I found where the other libraries were and headers and added them there and tried compiling my code which referenced them. This ended up working fine but upon install i get a handful of "undefined reference to" errors complaining that my functions are undefined..

Did i miss a step in including more .lib and .h files that would let build run but not install?

Any insight is appreciated, thanks!


Replies (15)

RE: Linux server, build works but install fails.. - Added by molator over 7 years ago

It's impossible to answer, if you provide nothing :).
Any log ?

RE: Linux server, build works but install fails.. - Added by AlexS over 7 years ago

Sorry about that totally spaced, here is what comes out in terminal:

CMakeFiles/ryzom_frontend_service.dir/fe_send_sub.cpp.o: In function `CFeSendSub::CSendBuffer::enableSendBuffer(bool)':
/home/test/code/ryzom/server/src/frontend_service/fe_send_sub.cpp:360: undefined reference to `testlib_close_buffer'
/home/test/code/ryzom/server/src/frontend_service/fe_send_sub.cpp:355: undefined reference to `testlib_reset_buffer'
CMakeFiles/ryzom_frontend_service.dir/fe_send_sub.cpp.o: In function `CFeSendSub::CSendBuffer::sendOutBox(NLNET::CUdpSock*)':
/home/test/code/ryzom/server/src/frontend_service/fe_send_sub.cpp:386: undefined reference to `testlib_get_maxsize'
/home/test/code/ryzom/server/src/frontend_service/fe_send_sub.cpp:395: undefined reference to `testlib_once'
CMakeFiles/ryzom_frontend_service.dir/fe_send_sub.cpp.o: In function `CFeSendSub::CSendBuffer::enableSendBuffer(bool)':
/home/test/code/ryzom/server/src/frontend_service/fe_send_sub.cpp:360: undefined reference to `testlib_close_buffer'
/home/test/code/ryzom/server/src/frontend_service/fe_send_sub.cpp:355: undefined reference to `testlib_reset_buffer'
CMakeFiles/ryzom_frontend_service.dir/fe_send_sub.cpp.o: In function `CFeSendSub::init(NLNET::CUdpSock*, std::tr1::unordered_map<NLNET::CInetAddress, CClientHost*, CInetAddressHashMapTraits, std::equal_to<NLNET::CInetAddress>, std::allocator<std::pair<NLNET::CInetAddress const, CClientHost*> > >*, CHistory*, CPrioSub*)':
/home/test/code/ryzom/server/src/frontend_service/fe_send_sub.cpp:81: undefined reference to `testlib_init'
collect2: ld returned 1 exit status
make[2]: *** [bin/ryzom_frontend_service] Error 1
make[1]: *** [ryzom/server/src/frontend_service/CMakeFiles/ryzom_frontend_service.dir/all] Error 2
make: *** [all] Error 2

RE: Linux server, build works but install fails.. - Added by molator over 7 years ago

Looks like you forgot to include the header file that define your fonctions in fe_send_sub.cpp
or the related lib to the project.

RE: Linux server, build works but install fails.. - Added by AlexS over 7 years ago

That was my initial reaction as well, although i assure you it's defined at the top of my file (#include "testlib.h") and i even went as far as to drop the library and header in the save frontend_service folder.

Yet it still can't find them even though it pulls many other headers from there.. Any ideas? I'm sort of unfamiliar with building on Linux so sorry if i'm not too helpful :)

RE: Linux server, build works but install fails.. - Added by molator over 7 years ago

You created your own lib ?
If so, you must add it in the command to link your project.

RE: Linux server, build works but install fails.. - Added by AlexS over 7 years ago

Ah okay, would this require modifying the CMake scripts?

EDIT: In the frontend_service folder i found this:

INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR} ${MYSQL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})

TARGET_LINK_LIBRARIES(ryzom_frontend_service
                        ryzom_adminmodules
                        ryzom_gameshare
                        ${LIBXML2_LIBRARIES}
                        ${MYSQL_LIBRARIES}
                        ${ZLIB_LIBRARIES}
                        nelmisc
                        nelnet
                        nelgeorges
                        nelligo)

Am i barking up the right tree? Would i want to add my include directory etc. here?

RE: Linux server, build works but install fails.. - Added by kervala over 7 years ago

Yes, you should add your include and lib directories :)

You can even create a CMakeModules/FindYourLib.cmake module using another module and adapting it.

So later you can use variables : ${YOUR_LIB_INCLUDE_DIRS} and ${YOUR_LIB_LIBRARIES}

RE: Linux server, build works but install fails.. - Added by AlexS over 7 years ago

Ah yes, although i am a little fuzzy still would the library name be the name of the .lib file? Also where would i put these files to have it look for them?

EDIT:
I see that is explained in the comment, although i wanna make sure library name is for the lib file.
Also where are the include paths relative to? And do i need to tell CMake to look for my new file anywhere?

RE: Linux server, build works but install fails.. - Added by kervala over 7 years ago

CMake modules are almost all using absolute paths but relative ones are related to current CMakeLists.txt being processed.

Or you can place your includes in ${EXTERNAL_INCLUDE_PATH} and your .lib in ${EXTERNAL_LIBRARY_PATH} which are already defined globally :)

RE: Linux server, build works but install fails.. - Added by AlexS over 7 years ago

Hmmm where are these defined so i can get a better idea of how this all fits together?

Also, do i need to edit the CMakeLists in the frontend_sevice if i put them in these globally defined paths?

RE: Linux server, build works but install fails.. - Added by kervala over 7 years ago

In fact, I was partly wrong. If you put your files in ${EXTERNAL_INCLUDE_PATH} and ${EXTERNAL_LIBRARY_PATH}, you'll still need to declare your .lib in a CMakeLists.txt.

If your .lib file is "yourlib.lib", you'll have to put :

TARGET_LINK_LIBRARIES(ryzom_frontend_service
                        ryzom_adminmodules
                        ryzom_gameshare
                        ${LIBXML2_LIBRARIES}
                        ${MYSQL_LIBRARIES}
                        ${ZLIB_LIBRARIES}
                        nelmisc
                        nelnet
                        nelgeorges
                        nelligo
                        yourlib)

RE: Linux server, build works but install fails.. - Added by AlexS over 7 years ago

Ah okay, and where would those external paths be defined?

Really thanks for your help, this has been stumping me for a while very new to CMake on linux..

RE: Linux server, build works but install fails.. - Added by kervala over 7 years ago

It checks in external, external_stlport, code/external or code/external_stlport with subfolders : "bin", "include" and "lib" (similar to /usr)

All is defined in code/CMakeModules/FindExternal.cmake so you can take a look at it :)

RE: Linux server, build works but install fails.. - Added by AlexS over 7 years ago

Thanks so much! Finally got it built, typing out the lib name by hand did it... Weird, but thank you for your patience :)

(1-15/15)