Issue
When the command "scons" is run in the root directory, scons will eventually run the command "g++ -o bin/program bin/cpp/main.o" which will return the error:
"undefined reference to 'dlopen', 'dlerror', 'dlsym', 'dlerror'"
This undefined reference issue can be resolved with the '-ldl' compile argument, but for some reason, scons won't append it.
How do I get scons to add the '-ldl' argument to the g++ command.
.
Project Setup
My project setup is as follows (simplified for stack overflow purposes):
projectFolder/
├──bin/
│ ├─cpp/
│ └─Future Compiled Binary
│
├──cpp/
│ ├─SConscript
│ └─main.cpp
│
└──SConstruct
main.cpp
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
...
int main(void) {
...
}
SConscript
# C++
env = Environment()
env.Append(CXXFLAGS = '-ldl')
print env["CXXFLAGS"]
srcFiles = ['main.cpp']
env.Program('../program', srcFiles)
SConstruct
SConscript('cpp/SConscript', variant_dir='bin/cpp')