Basic question about compiling Chaiscript with minGW g++


I am trying to compile Chaiscript using g++ in the command line, but I am running into some issues that stem from my lack of understanding. I am trying to compile this simple test program:

#include <chaiscript/chaiscript.hpp>
#include <iostream>

int main()
	int x = 5;
	chaiscript::ChaiScript chai;
	chai.add(chaiscript::var(x), "x");
	return 0;

However, I am met with this error having to do with the -ldl compiler flag:

C:\Users\Kai\Dropbox\progs>g++ -std=c++11 -o test test.cpp -I C:\chaiscript\incl
ude -ldl
ld.exe: cannot find -ldl
collect2.exe: error: ld returned 1 exit status

What basic understanding of the library am I missing?


-ldl is only needed on unix systems.

But you’ll also run into a problem that mingw is a bit buggy and you need to compile with at least -O1 to get it to build.