0

I'm trying to create a shared library in C++ using eclipse IDE on linux. But I'm getting this error and I can't find the problem:

23:42:12 **** Incremental Build of configuration Release for project GE ****
make all 
Building file: ../GE/Application.cpp
Invoking: GCC C++ Compiler
std=c++1y -DGE_PLATFORM_LINUX -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"GE/Application.d" -MT"GE/Application.o" -o "GE/Application.o" "../GE/Application.cpp"
/bin/sh: 1: -DGE_PLATFORM_LINUX: not found
make: [GE/subdir.mk:20: GE/Application.o] Error 127 (ignored)
Finished building: ../GE/Application.cpp

Building target: libGE.so
Invoking: GCC C++ Linker
g++ -shared -o "libGE.so"  ./GE/Application.o   
g++: error: ./GE/Application.o: No such file or directory
g++: fatal error: no input files
compilation terminated.
make: *** [makefile:47: libGE.so] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

23:42:12 Build Failed. 1 errors, 0 warnings. (took 317ms)

This is my configuration: Preprocessor Settings

Dialect

The preprocessor GE_PLATFORM_LINUX is required by the library.

PrograMed IP
  • 19
  • 1
  • 8
  • Seems like it is missing the compiler from the command line and trying to execute the command line arguments instead. The first argument `std=c++1y` is a valid shell variable assignment and tries to execute the second argument. – drescherjm Mar 14 '19 at 20:56
  • @drescherjm So how to solve it ? – PrograMed IP Mar 14 '19 at 21:01
  • Probably a setting in eclipse. Unfortunately I can't help with that. – drescherjm Mar 14 '19 at 21:02
  • I think I shouldn't use Eclipse... I will try tomorrow on Windows with Visual Studio, I will look for exporting the lib to linux later. – PrograMed IP Mar 14 '19 at 21:04
  • 1
    I won't disagree with that... – drescherjm Mar 14 '19 at 21:05
  • 2
    @PrograMedIP this is opening a big can of worms indeed, but I really fail to see why **anyone** would use Eclipse. On the other hand, resilience and resourcefulness are invaluable for software developer, so you might want to resolve this problem just for the challenge. You can learn a thing or two in the process. – SergeyA Mar 14 '19 at 21:07
  • @SergeyA It's actually because I found that it's one of the most used (and a little bit good looking) IDEs on linux, so I went for it... – PrograMed IP Mar 14 '19 at 21:08
  • @PrograMedIP anybody who uses IDE on Linux should be using CLion. But why do you need IDE in the first place? :) – SergeyA Mar 14 '19 at 21:10
  • Good looks aren't everything. In technical areas they are indeed one of the last things to look for, but not in marketing... – Murphy Mar 14 '19 at 21:12
  • 1
    If I could make a suggestion I don't feel is actually an answer to your exact question but might save you some trouble: If this is a new project, this might be a great time to pick up and learn a nice **free** tool called Cmake, which makes configuring your project to build *vastly* simpler overall, and can generate IDE solutions/workspaces for you to jump into, including Eclipse. – Tzalumen Mar 14 '19 at 21:25

2 Answers2

0

Your compilation command is all messed up.

std=c++1y -DGE_PLATFORM_LINUX...

/bin/sh: 1: -DGE_PLATFORM_LINUX: not found make: [GE/subdir.mk:20: GE/Application.o] Error 127 (ignored)

This means that the actual compiler (g++) was not invoked, and it is just the arguments following it, which is than treated by shell as a command, which obviously does not exist. Check your make file to see what is there.

SergeyA
  • 61,605
  • 5
  • 78
  • 137
0
std=c++1y -DGE_PLATFORM_LINUX -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"GE/Application.d" -MT"GE/Application.o" -o "GE/Application.o" "../GE/Application.cpp"

In this line, the C++ compiler command is missing, which results in the shell trying to interpret -DGE_PLATFORM_LINUX as the command to execute. That results in the error showing up in the next line:

/bin/sh: 1: -DGE_PLATFORM_LINUX: not found

Thus the object file isn't built, and missing at link time. Why the missing command is accepted by Eclipse, and that error is ignored, are different questions.

Solution: Make sure you've set the correct compiler command; the linker call shows how it's supposed to look like:

g++ -shared -o "libGE.so"  ./GE/Application.o   

From https://stackoverflow.com/a/38220551/5794048: enter image description here

Murphy
  • 3,827
  • 4
  • 21
  • 35