问题描述
我正在尝试在INSEL中创建一个用户定义的块,该块需要C ++进行编程,并使用gfortran进行链接.
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());
设置为我的随机数生成器的种子.当我使用g ++(gcc v.5.1.0)进行编译时,它没有显示任何错误或警告.我的编译命令是
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拥有我所有的.cpp程序.当我尝试使用gfortran将其链接到时,出现提示:
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)
我得到一个错误:
collect2.exe:错误:ld返回1退出状态makefile:11:配方 目标'inselUB'失败
collect2.exe: error: ld returned 1 exit status makefile:11: recipe for target 'inselUB' failed
make:*** [inselUB]错误1
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?
操作系统:Win 7
OS: Win 7
推荐答案
通常,在使用gfortran链接C ++对象时,需要链接-lstdc++
.如果您与g ++链接,则必须链接-lgfortran
.
Normally you need to link -lstdc++
when linking C++ objects with gfortran. If you linked with g++ you would have to link -lgfortran
.
这篇关于与gfortran链接时对`std :: chrono :: _ V2 :: system_clock :: now()'的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!