1

I am trying to create an user defined block in INSEL which requires C++ to program and I link it using gfortran.

I have the following code in my program

// Setting seed for random number generators
unsigned seed = static_cast<int> (std::chrono::system_clock::now().time_since_epoch().count());

to set as a seed to my random number generator. When i compile it using g++ (gcc v.5.1.0) it shows no error or warning. My compiling command is

g++ -O0 -Wall -c -g3 -std=c++14 -fmessage-length=0 $(sourcesC)

sourcecC has all my .cpp programs. BUt when I try linking it using gfortran with:

gfortran -shared -o C:\***\inselUB.dll -Wall -L./ -linselTools $(objects) 

I get an error:

C:***\resources/../src/constants.h:54: undefined reference to `std::chrono::_V2::system_clock::now()'

collect2.exe: error: ld returned 1 exit status makefile:11: recipe for target 'inselUB' failed

make: *** [inselUB] Error 1

I am just a beginner to this type of interfacing. may be its a simple error. Could anyone suggest me an solution?

OS: Win 7

akki
  • 47
  • 1
  • 8

1 Answers1

5

Normally you need to link -lstdc++ when linking C++ objects with gfortran. If you linked with g++ you would have to link -lgfortran.