Author Topic: C++, Lua 5.3, CMake, undefined reference  (Read 1193 times)

0 Members and 1 Guest are viewing this topic.

Offline darknight_1980

  • Neuling
  • *
  • Posts: 9
  • Batman + Heisenberg = EPICNESS
  • Branch: stable
  • Desktop: KDE
  • GPU Card: nVidia GTX 760
  • GPU driver: non-free
  • Skill: Novice
C++, Lua 5.3, CMake, undefined reference
« on: 13. January 2016, 09:32:40 »
I'm trying to use Lua in my C++ program. My OS is Manjaro 15.12. I downloaded the Lua 5.3 source code, and compiled it as C++ code (I really need the exception handling instead of longjmp), with this line:

Code: [Select]
make "CC=g++" linux
Then sudo make install to get Lua installed in /usr/local. Everything looks fine. My CMake version seems to be updated:

Code: [Select]
cmake --version
cmake version 3.4.1

In my CMake file, I find Lua like this:

Code: [Select]
find_package(Lua REQUIRED)
include_directories(${LUA_INCLUDE_DIR})

message("   *** Lua include: ${LUA_INCLUDE_DIR}")
message("   *** Lua lib: ${LUA_LIBRARIES}")

After running this command:

Code: [Select]
cd build
cmake -G "Unix Makefiles" ..

The include folder is properly detected in /usr/local/include, but the library itself, is found as /usr/lib64/liblua5.1.so;/usr/lib64/libm.so, wich is not the installation I did (and its version 5.1, I want 5.3). CMake says:

Code: [Select]
Found Lua: /usr/lib64/liblua5.1.so;/usr/lib64/libm.so (found version "5.3.2")
Its like it is "mixing" the two versions. Running make throws a lot of undefined references. Previously in my CMake file, I find other libraries (SDL2 compiled by me, OpenGL, glew), and they seem to work. The only errors I got are for the Lua library. Of course, I'm adding the libraries to my target_link_libraries command

How can I fix this?
I don't care if I have to eliminate the older Lua version, as long as it doesn't break my OS. This command:

Code: [Select]
sudo pacman -R lua51
Says:
Code: [Select]
error: failed to prepare transaction (could not satisfy dependencies)
:: elinks: requires lua51

I need CMake to find the Lua library I have manually installed from sources
Please help

Offline simgin

  • Held Mitglied
  • *****
  • Posts: 774
  • Branch: All.
  • Desktop: XFCE+Alpine Linux, Mate+Fedora, Ubuntu Server + Mate and NoX+LinuxBBQ
  • GPU Card: GeForce 8600M & GT 555M 2GB
  • Skill: Intermediate
Re: C++, Lua 5.3, CMake, undefined reference
« Reply #1 on: 28. January 2016, 23:15:05 »
<bump>

You need elinks? Excuse my ignorance.
If you do and want to force an uninstall of a package.


Code: [Select]
pacman -Rdd lua51

cheerio

simgin

Offline darknight_1980

  • Neuling
  • *
  • Posts: 9
  • Batman + Heisenberg = EPICNESS
  • Branch: stable
  • Desktop: KDE
  • GPU Card: nVidia GTX 760
  • GPU driver: non-free
  • Skill: Novice
Re: C++, Lua 5.3, CMake, undefined reference
« Reply #2 on: 02. February 2016, 06:52:51 »
You need elinks?

No, I dont.. It comes in my Manjaro installation
Here is what I did (I know its evil)  >:D

Code: [Select]
sudo pacman -R bmenu elinks lua51
Thanks anyway  ;D