• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Linux Compilation

EduardoDantas

Intermediate OT User
Joined
Sep 25, 2013
Messages
192
Solutions
5
Reaction score
143
Location
Brazil
Hi. Good evening guys.
Sorry if it sounds like a stupid question, though, I'm having trouble compiling on linux (ubuntu) and would like to know if anyone knows how to resolve these errors.
On windows it normally goes, however I do not handle much of cmake and linux compilation, I have now started to mess with this S.O.

Code:
/src/signals.cpp:87: undefined reference to `Signals::sigintHandler()'
CMakeFiles/tfs.dir/src/rsa.cpp.o: In function `RSA::RSA()':
/src/rsa.cpp:26: undefined reference to `__gmpz_init'
CMakeFiles/tfs.dir/src/rsa.cpp.o: In function `RSA::~RSA()':
/src/rsa.cpp:32: undefined reference to `__gmpz_clear'
CMakeFiles/tfs.dir/src/rsa.cpp.o: In function `RSA::setKey(char const*, char const*)':
/src/rsa.cpp:39: undefined reference to `__gmpz_init2'
/src/rsa.cpp:40: undefined reference to `__gmpz_init2'
/src/rsa.cpp:41: undefined reference to `__gmpz_init'
/src/rsa.cpp:43: undefined reference to `__gmpz_set_str'
/src/rsa.cpp:44: undefined reference to `__gmpz_set_str'
/src/rsa.cpp:47: undefined reference to `__gmpz_set_ui'
/src/rsa.cpp:50: undefined reference to `__gmpz_mul'
/src/rsa.cpp:53: undefined reference to `__gmpz_init2'
/src/rsa.cpp:54: undefined reference to `__gmpz_init2'
/src/rsa.cpp:55: undefined reference to `__gmpz_init2'
/src/rsa.cpp:57: undefined reference to `__gmpz_sub_ui'
/src/rsa.cpp:58: undefined reference to `__gmpz_sub_ui'
/src/rsa.cpp:61: undefined reference to `__gmpz_mul'
/src/rsa.cpp:64: undefined reference to `__gmpz_invert'
/src/rsa.cpp:66: undefined reference to `__gmpz_clear'
/src/rsa.cpp:67: undefined reference to `__gmpz_clear'
/src/rsa.cpp:68: undefined reference to `__gmpz_clear'
/src/rsa.cpp:70: undefined reference to `__gmpz_clear'
/src/rsa.cpp:71: undefined reference to `__gmpz_clear'
CMakeFiles/tfs.dir/src/rsa.cpp.o:/src/rsa.cpp:72: more undefined references to `__gmpz_clear' follow
CMakeFiles/tfs.dir/src/rsa.cpp.o: In function `RSA::decrypt(char*) const':
/src/rsa.cpp:78: undefined reference to `__gmpz_init2'
/src/rsa.cpp:79: undefined reference to `__gmpz_init2'
/src/rsa.cpp:81: undefined reference to `__gmpz_import'
/src/rsa.cpp:84: undefined reference to `__gmpz_powm'
/src/rsa.cpp:86: undefined reference to `__gmpz_sizeinbase'
/src/rsa.cpp:88: undefined reference to `__gmpz_export'
/src/rsa.cpp:90: undefined reference to `__gmpz_clear'
/src/rsa.cpp:91: undefined reference to `__gmpz_clear'
CMakeFiles/tfs.dir/src/rsa.cpp.o: In function `RSA::RSA()':
/src/rsa.cpp:27: undefined reference to `__gmpz_init2'
CMakeFiles/tfs.dir/src/rsa.cpp.o: In function `RSA::~RSA()':
/src/rsa.cpp:33: undefined reference to `__gmpz_clear'
collect2: error: ld returned 1 exit status
make[2]: * [tfs] Error 1
make[1]: * [CMakeFiles/tfs.dir/all] Error 2
make: * [all] Error 2
 
Thanks for the response and for the help.
I know it's a bit of a question, but as I mentioned, I'm starting linux and everything is too different from windows.
Many thanks, I will install the libs and if everything works return here with the answer.
 
Even installing the libs did not work.
I was surprised because I have another source that I have compiled normally and it has rsa.cpp and rsa.h the same as the one I am trying to compile.

Any idea what that might be?
PS: This happened after I added the revscripts:

# 2558:

# 2569 https://github.com/otland/forgottenserver/commit/38eb0cde9eb579765a7e9588eb3d2143dd55a19

# 2571

But, compiling normal at windows
 
I found this thread while looking for a solution on google.
The link to the whole documentation is just unhelpful and the thread doesn't
actually explain how the problem was solved so I thought I'll share my way of solving it.

First of all, we are going to need libgmp3-dev, it can be easily installed with

Code:
sudo apt install libgmp3-dev
Then what we'll need to do is include FindGMP in the root folder file CMakeLists.txt like so:

Makefile:
include(FindGMP)

Fortunately, the project which I am using has already FindGMP.cmake file in the cmake folder, but if it helps anyone i'll include what it contains.
Makefile:
 Locate GMP library
# This module defines
#   GMP_FOUND
#   GMP_INCLUDE_DIR
#   GMP_LIBRARIES

find_path(GMP_INCLUDE_DIR NAMES gmp.h)
find_library(GMP_LIBRARIES NAMES gmp libgmp)
find_library(GMPXX_LIBRARIES NAMES gmpxx libgmpxx)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GMP DEFAULT_MSG GMP_INCLUDE_DIR GMP_LIBRARIES GMPXX_LIBRARIES)

mark_as_advanced(GMP_INCLUDE_DIR GMP_LIBRARIES GMPXX_LIBRARIES)

These constants (GMP_INCLUDE_DIR, GMP_LIBRARIES and GMPXX_LIBRARIES) which are defined by this cmake file are very important because we'll need them again in the CMakeLists.txt file:

we'll just need to add them like that (in my case i have already some libraries so i am appending them to the end):

Makefile:
include_directories(${MYSQL_INCLUDE_DIR} ${LUA_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${PUGIXML_INCLUDE_DIR} ${Crypto++_INCLUDE_DIR} ${GMP_INCLUDE_DIR})
target_link_libraries(tfs ${MYSQL_CLIENT_LIBS} ${LUA_LIBRARIES} ${Boost_LIBRARIES} ${Boost_FILESYSTEM_LIBRARY} ${PUGIXML_LIBRARIES} ${Crypto++_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${GMP_LIBRARIES} ${GMPXX_LIBRARIES})

Hope that's more helpful, cheers :)
 
Back
Top