Z0q
Z0q

Reputation: 1883

How do I compile and deliver my application without requiring installation of shared libraries on other machines

On my Ubuntu machine I installed libGLEW. However, I did not install it on my other Ubuntu machine. It works on my compiling machine, but now I received the following error after copying my executable to my other machine.

I want to find a solution where I don't have to require my other machine to install the library. Maybe I can simply share the file along with the executable, like I would do in Windows with DLL files? Would that be possible? And if so, how do I do that?

error while loading shared libraries: libGLEW.so.2.1: cannot open shared object file: No such file or directory

In CMake, I used the following relevant pieces of code:

set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -g" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -g" )

include_directories(
    ...
    "/usr/include/GL" # Also includes glew.h
)

add_executable( ${PROJECT_NAME}
    ${PROJECT_SRC}
)

target_link_libraries( ${PROJECT_NAME}
    ...
    "GLEW"
)

Upvotes: 0

Views: 615

Answers (2)

Z0q
Z0q

Reputation: 1883

To solve the issue for my situation, I added glew.c to my source files which solves the issue.

Upvotes: 0

Maybe I can simply share the file along with the executable, like I would do in Windows with DLL files?

It 'depends' on the 'dependencies'.

Use the command ldd to figure out, which libraries are required by a library or program. Those required libraries have to be present (installed) on the target system.

Even if a required library is installed on the target system, it could be possible, that the required version is not available.

That's why the different (linux) systems have their package management systems, which are able to resolve the dependencies and install them automatically.

Upvotes: 2

Related Questions