New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mingw平台上使用-fopenmp选项进行链接的问题 #151

Closed
knightjun opened this Issue Nov 13, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@knightjun
Copy link

knightjun commented Nov 13, 2017

在使用xmake构建的时候出现了一个问题:
平台:mingw
由于我需要使用openmp,所以我在编译和链接的时候都加上了选项
add_cxxflags("-fopenmp")
add_shflags("-fopenmp")
在编译的过程没有问题,但是链接的时候并没有-fopenmp选项。查看详细输出是在编译的时候检查选项有效,链接的时候检查选项无效,我手动加上-fopenmp运行链接命令是可以成功链接的

编译的提示:checking for the flags(g++) -fopenmp ... ok
链接的提示:checking for the flags(g++) -fopenmp ... no

@knightjun knightjun changed the title mingw平台上使用-fopenmp选项进行连接的问题 mingw平台上使用-fopenmp选项进行链接的问题 Nov 13, 2017

@waruqi

This comment has been minimized.

Copy link
Member

waruqi commented Nov 14, 2017

我现在暂时没有 win/mingw的环境,你可以到xmake的安装目录下,修改下 xmake/modules/detect/tools/gcc/has_flags.lua 脚本,把里面的 os.nuldev() 批量替换成os.tmpfile() 后,在重新 xmake f -c; xmake -r -v清下缓存配置,检测下试试。。

如果ok,我之后提交下修复,如果还不行,可以帮忙加点print, 在_check_try_running()/islinker/里面的那个 try 块调下看看。。

@knightjun

This comment has been minimized.

Copy link

knightjun commented Nov 14, 2017

@waruqi 按照你说的改了脚本之后,链接的时候能检测到-fopenmp,可是编译的时候检测不到-fopenmp选项

@waruqi

This comment has been minimized.

Copy link
Member

waruqi commented Nov 14, 2017

大概了解了,你可以先就改下islinker分支里面的那个nuldev:

if islinker then
     os.nuldev() -> os.tmpfile()
end

之后我再做个更好的修复。

@knightjun

This comment has been minimized.

Copy link

knightjun commented Nov 14, 2017

问题解决,十分感谢,另外有一个小问题,在windows用mingw 生成动态链接库的时候链接选项要加上“-Wl,--out-implib,$(buildir)/lib***.a”所生成的动态链接库才能使用,xmake默认是没有加上这个的,希望下次更新的时候能加到默认的选项中

@waruqi

This comment has been minimized.

Copy link
Member

waruqi commented Nov 14, 2017

好的 等我装完环境后 这块改进下

@knightjun knightjun closed this Nov 14, 2017

@waruqi

This comment has been minimized.

Copy link
Member

waruqi commented Nov 16, 2017

我更新了下 安装包,对mingw/windows下进行了一些改进,修复了 -fopenmp的问题,并且动态库自动加上了 -Wl,--out-implib

你可以试试:xmake-v2.1.9-dev

也可以从release v2.1.8下面,找到相关文件进行下载安装。xmake-v2.1.9-dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment