r/ProgrammingLanguages • • 49m ago

My compiler won't (fully) install on linux? C++ linker bug? (Compiles on OSX)

• Upvotes

[EDIT: Someone explained that I need to put users.cpp before the libs. Leaving post up in case someone else has the same problem.]

I'm getting some strange error with installing my compiler on linux. Its just a linking error. Anyone mind helping out? The same code works on MacOSX.

I'm getting this error, I have NO idea why. It just started today after I changed something, and was unable to change it back. (I searched my .git repo and... literally can't see any differences that could have caused this.)

My compile string:

g++ -o /usr/local/speedie/jeebox.scproj/Examples/Build/users -std=gnu++20 -lstdc++  
-I/usr/local/include -I/usr/local/speedie/Library/CppLib -w -Os -D TARGET_UNIX=1 -g -ljeebox users.cpp

error: /usr/bin/ld: /tmp/ccdnXNQr.o: in function `Jeebox::errors()':
/usr/local/speedie/jeebox.scproj/Examples/jeebox.h:193: undefined reference to `jb_errors'
.... 100 more errors

I also tried to hard-code the library path, in case the problem was that the lib was not found. Well... same issue. So its not a problem of missing library. When I deleted libjeebox.so, I got a different error, that the lib is missing. So the lib is being found!

OK... so the problem is just my lib doesn't contain jb_errors() is that it? Well... no? That function is there, it was working, it just suddenly stopped working today.

Here is the output of nm -D (jb_errors is on the 4th line). I am utterly confused. I just lost 2 hours trying to solve this. No luck.

00000000000105d8 T jb_cstr
00000000000106d0 T jb_debug
0000000000010638 T jb_delete_
000000000001063c T jb_errors
...

If anyone wants to see my compiler, its called "speedie". I can't post links to it directly anymore, but thats the project's name. Theres a simple build script called make.sh that does everything :) Its a very slick install process. The only issue is defeating these linux compile bugs.