首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未定义对nlopt_的引用...符号

未定义对nlopt_的引用...符号
EN

Stack Overflow用户
提问于 2019-05-02 09:08:08
回答 1查看 421关注 0票数 0

我是Fortran的新手,这听起来可能是个愚蠢的问题。在编译NLOPT Wiki中作为示例发布的Fortran代码时,我遇到了一个错误。

我使用以下命令在Ubuntu 18.04 LTS中编译:

代码语言:javascript
复制
gfortran example-nlopt.f90 -o example-nlopt -I/usr/local/include/

在终端中产生以下错误:

代码语言:javascript
复制
/tmp/ccbAim6b.o: In function `MAIN__':
example-nlopt.f90:(.text+0x26): undefined reference to `nlo_create_'
example-nlopt.f90:(.text+0x42): undefined reference to `nlo_get_lower_bounds_'
example-nlopt.f90:(.text+0x67): undefined reference to `nlo_set_lower_bounds_'
example-nlopt.f90:(.text+0x8a): undefined reference to `nlo_set_min_objective_'
example-nlopt.f90:(.text+0xca): undefined reference to `nlo_add_inequality_constraint_'
example-nlopt.f90:(.text+0x10e): undefined reference to `nlo_add_inequality_constraint_'
example-nlopt.f90:(.text+0x12d): undefined reference to `nlo_set_xtol_rel_'
example-nlopt.f90:(.text+0x164): undefined reference to `nlo_optimize_'
example-nlopt.f90:(.text+0x305): undefined reference to `nlo_destroy_'
collect2: error: ld returned 1 exit status
EN

回答 1

Stack Overflow用户

发布于 2019-05-03 06:50:57

根据我在nlopt的文档(https://nlopt.readthedocs.io/en/latest/NLopt_Installation/#changing-the-installation-directory)中看到的,看起来您只需要指定要链接到的库。也许你可以试试这个:

代码语言:javascript
复制
gfortran  -I/usr/local/include/ -L/usr/local/lib example-nlopt.f90 -o example-nlopt -lnlopt -lm

这里假设本地文件位于/usr/ libnlopt.so /lib中,如果没有,则使用-L选项指向它的位置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55944475

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档