SpaceCadetPinball icon indicating copy to clipboard operation
SpaceCadetPinball copied to clipboard

Builds as a Shared Library instead of an application under Linux

Open Kippykip opened this issue 3 years ago • 2 comments

I'm pretty stumped on how to work around this, I've been staying up for hours and now it's 6:30am and I still can't figure out how to make CMake change it's output to an Executable instead of a shared library. No command prefixes I've searched have worked (I keep seeing something about no-pie but nope, nothing)

Any workarounds? It works in the terminal via ./SpaceCadetPinball but then I can't have a shortcut or launcher to it.

Kippykip avatar Nov 25 '21 20:11 Kippykip

Whew ok finally figured it out: open CMakeLists.txt, and add this somewhere

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no-pie")

make clean cmake . make

Kippykip avatar Nov 25 '21 20:11 Kippykip

I believe your claims about shared library are false. CMake add_executable should always produce an executable, example:./bin/SpaceCadetPinball: ELF 64-bit LSB pie executable.

Your problem is that your GUI refuses to launch ELF compiled with Position Independent Executable. CMake by default does not use PIE for executables, and I did not enable it in the project. For PIE to appear, it must be forced by the compiler, probably gcc in your case. My gcc also does this, while clang does not. So, you have a conflict of interests: compiler wants more secure ELFs, GUI works against that; a typical Linux problem.

Your workaround that suppresses forced PIE is correct. Another option is to try other compiler.

k4zmu2a avatar Nov 26 '21 06:11 k4zmu2a

PIE ELF handling should be fixed upstream.

k4zmu2a avatar Oct 16 '23 07:10 k4zmu2a