NLPIR icon indicating copy to clipboard operation
NLPIR copied to clipboard

mac如何使用c++的动态库?

Open nlpjoe opened this issue 6 years ago • 11 comments

在mac里使用linux64的libNLPIR.so Makefile文件内容如下:

qa_test:
	g++ src/*.cpp -I ./include/ -Wall -Wunused -DOS_LINUX -std=c++11 -L. -lNLPIR -lboost_serialization  -lpthread -g -O3  -msse4.2 -o run_env/bin/qa_test test/qa_test.cpp

make出现如下错误:

ld: symbol(s) not found for architecture x86_64

请问是我使用的库不对吗?

nlpjoe avatar Mar 09 '18 11:03 nlpjoe

我找到了#62

nlpjoe avatar Mar 09 '18 13:03 nlpjoe

我使用正确的包make成功后,运行报如下错误请问可能是什么原因?

dyld: Library not loaded: ../../../bin/ICTCLAS/libNLPIR.so

nlpjoe avatar Mar 09 '18 15:03 nlpjoe

同样的代码,我在linux上用对应的包make过后能跑起来,但是在mac上用对应的包就是一直出这个bug!

nlpjoe avatar Mar 09 '18 15:03 nlpjoe

貌似MAC需要dylib包,我尝试过把LINUX下的SO文件改名成为.dylib,结果还是不行。

SuperUNITE avatar Mar 10 '18 02:03 SuperUNITE

可以make无法运行

                                邮箱:[email protected]
                            
                    
                
            
        
    

签名由 网易邮箱大师 定制 在2018年03月10日 10:16,SuperUNITE 写道: 貌似MAC需要dylib包,我尝试过把LINUX下的SO文件改名成为.dylib,结果还是不行。

—You are receiving this because you modified the open/close state.Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/NLPIR-team/NLPIR","title":"NLPIR-team/NLPIR","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/NLPIR-team/NLPIR"}},"updates":{"snippets":[{"icon":"PERSON","message":"@SuperUNITE in #115: 貌似MAC需要dylib包,我尝试过把LINUX下的SO文件改名成为.dylib,结果还是不行。"}],"action":{"name":"View Issue","url":"https://github.com/NLPIR-team/NLPIR/issues/115#issuecomment-371994574"}}}

nlpjoe avatar Mar 10 '18 02:03 nlpjoe

在github下载mac版的动态库libNLPIR.dylib,你的编译过程加载动态库,需要吧动态库放入系统的lib和你的boost库一样

发自我的 iPhone

在 2018年3月10日,上午10:22,Jzzhou <[email protected]mailto:[email protected]> 写道:

可以make无法运行

邮箱:[email protected]mailto:[email protected]

签名由 网易邮箱大师 定制 在2018年03月10日 10:16,SuperUNITE 写道: 貌似MAC需要dylib包,我尝试过把LINUX下的SO文件改名成为.dylib,结果还是不行。

—You are receiving this because you modified the open/close state.Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/NLPIR-team/NLPIR","title":"NLPIR-team/NLPIR","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/NLPIR-team/NLPIR"}},"updates":{"snippets":[{"icon":"PERSON","message":"@SuperUNITE in #115: 貌似MAC需要dylib包,我尝试过把LINUX下的SO文件改名成为.dylib,结果还是不行。"}],"action":{"name":"View Issue","url":"https://github.com/NLPIR-team/NLPIR/issues/115#issuecomment-371994574"}}}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/NLPIR-team/NLPIR/issues/115#issuecomment-371995012, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALqUMGVyoHrPGIrHBBBPW3JUk6g5KNF_ks5tczjpgaJpZM4SkH4O.

phylieac avatar Mar 10 '18 03:03 phylieac

我在/usr/local和LD_LIBRARY_PATH里都放了dylib的库,还是找不到

nlpjoe avatar Mar 11 '18 03:03 nlpjoe

报错如下:

dyld: Library not loaded: ../../../bin/ICTCLAS/libNLPIR.so
  Referenced from: xxx
  Reason: image not found

nlpjoe avatar Mar 11 '18 03:03 nlpjoe

在这里找到了解决方法 #5

install_name_tool -change ../../../bin/ICTCLAS/libNLPIR.so libNLPIR.dylib bin/qa_test

nlpjoe avatar Mar 11 '18 06:03 nlpjoe

image

我想请问一下,mac上用CLion的控制台作为输入文本,分词结果乱码应该怎么调?我试过UTF8编码和GBK编码都不行

nlpjoe avatar Mar 11 '18 08:03 nlpjoe

关于编码,在初始化函数中传参,0是gbk,1 utf8,再者,传入分词函数的数据也应是utf8,有关编码的,只有这两处

发自我的 iPhone

在 2018年3月11日,下午4:10,Jzzhou <[email protected]mailto:[email protected]> 写道:

[image]https://user-images.githubusercontent.com/9483969/37251164-6a511dc8-2545-11e8-8314-a2a8977bf9eb.png

我想请问一下,mac上用CLion的控制台作为输入文本,分词结果乱码应该怎么调?我试过UTF8编码和GBK编码都不行

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/NLPIR-team/NLPIR/issues/115#issuecomment-372096852, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALqUMNB8J5g5_RFtytdIm7uQ39PRoifqks5tdNoDgaJpZM4SkH4O.

phylieac avatar Mar 11 '18 09:03 phylieac