August 24, 2012 How to build programs with gdc installed in /opt/gdc (using SCons)? | ||||
---|---|---|---|---|
| ||||
I come from a Java background, using mostly just IDEs to handle builds, so I'm very confused about how all this linking is done. I installed GDC from source into /opt/gdc, and I'm trying to build a simple program using SCons. After a lot of experimenting, I came up with this SConstruct file: DefaultEnvironment(DC='/opt/gdc/bin/gdmd') Program('helloworld', 'main.d', LIBPATH='/opt/gdc/lib64', LIBS='gphobos2') When I run scons, these commands are executed: /opt/gdc/bin/gdmd -I. -c -ofmain.o main.d Use of uninitialized value $ENV{"HOME"} in concatenation (.) or string at /opt/gdc/bin/gdmd line 186. gcc -o helloworld main.o -L/opt/gdc/lib64 -lgphobos2 then, I get a bunch of undefined reference errors like this: /opt/gdc/lib64/libgphobos2.a(monitor_.o): In function `_STI_monitor_staticctor': /home/ed/code/gdc/gdc/dev/gcc-4.6.2/objdir/x86_64-unknown-linux-gnu/libphobos/../../../libphobos/rt/monitor_.d:191: undefined reference to `pthread_mutexattr_init' /home/ed/code/gdc/gdc/dev/gcc-4.6.2/objdir/x86_64-unknown-linux-gnu/libphobos/../../../libphobos/rt/monitor_.d:192: undefined reference to `pthread_mutexattr_settype' I also don't know why it's saying these files are in /home/ed/... That's where I compiled them from before installing to /opt, but they are not there anymore. The /opt/gdc directory structure is: $ ls /opt/gdc bin include lib lib32 lib64 libexec share So, what's going on here, and how do I go about building the helloworld program? |
August 24, 2012 Re: How to build programs with gdc installed in /opt/gdc (using SCons)? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ed | Nevermind, I think I figured it out. Looks like libgphobos2 depends on libm, libpthread, and librt. So, changing the SConstruct file to: DefaultEnvironment(DC='/opt/gdc/bin/gdmd') Program('helloworld', 'main.d', LIBPATH=['/opt/gdc/lib64','/usr/lib'], LIBS=['gphobos2','m','pthread','rt']) Solves the problem. Though, if there's a better way to do things, feel free to let me know. |
Copyright © 1999-2021 by the D Language Foundation