Skip to content
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

linux版编译问题 #3

Open
bixiang opened this issue Mar 26, 2018 · 9 comments
Open

linux版编译问题 #3

bixiang opened this issue Mar 26, 2018 · 9 comments

Comments

@bixiang
Copy link

bixiang commented Mar 26, 2018

用linux版本时,编译后不能自动生成pyctp文件,该如何解决

@shizhuolin
Copy link
Owner

不应出现此现象,检查是否忘记安装 python-devel 库.

@bixiang
Copy link
Author

bixiang commented Mar 26, 2018

已经装了,我用的是ubuntu 16.04,已经装了python-dev。

@shizhuolin
Copy link
Owner

执行python3 setup.py build后
pyctp.......so 文件应在build目录中自动生成,
如失败,把错误信息贴上来,

@bixiang
Copy link
Author

bixiang commented Mar 26, 2018

bixiang@bixiang-ThinkCentre-M8600t-N085:~/PyCTP$ python3 setup.py build
running build
running build_ext
building 'PyCTP' extension
creating build
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6tVwKN/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./v6.3.6_20160606_api_tradeapi_linux64 -I/usr/include/python3.5m -c ./src/stdafx.cpp -o build/temp.linux-x86_64-3.5/./src/stdafx.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6tVwKN/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./v6.3.6_20160606_api_tradeapi_linux64 -I/usr/include/python3.5m -c ./src/PyCTP.cpp -o build/temp.linux-x86_64-3.5/./src/PyCTP.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6tVwKN/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./v6.3.6_20160606_api_tradeapi_linux64 -I/usr/include/python3.5m -c ./src/UserApiDataType.cpp -o build/temp.linux-x86_64-3.5/./src/UserApiDataType.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6tVwKN/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./v6.3.6_20160606_api_tradeapi_linux64 -I/usr/include/python3.5m -c ./src/UserApiStruct.cpp -o build/temp.linux-x86_64-3.5/./src/UserApiStruct.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6tVwKN/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./v6.3.6_20160606_api_tradeapi_linux64 -I/usr/include/python3.5m -c ./src/MdApi.cpp -o build/temp.linux-x86_64-3.5/./src/MdApi.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-6tVwKN/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I./v6.3.6_20160606_api_tradeapi_linux64 -I/usr/include/python3.5m -c ./src/TraderApi.cpp -o build/temp.linux-x86_64-3.5/./src/TraderApi.o -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
creating build/lib.linux-x86_64-3.5
x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fdebug-prefix-map=/build/python3.5-6tVwKN/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/./src/stdafx.o build/temp.linux-x86_64-3.5/./src/PyCTP.o build/temp.linux-x86_64-3.5/./src/UserApiDataType.o build/temp.linux-x86_64-3.5/./src/UserApiStruct.o build/temp.linux-x86_64-3.5/./src/MdApi.o build/temp.linux-x86_64-3.5/./src/TraderApi.o -L./v6.3.6_20160606_api_tradeapi_linux64 -Wl,--enable-new-dtags,-R./ -lthostmduserapi -lthosttraderapi -o build/lib.linux-x86_64-3.5/PyCTP.cpython-35m-x86_64-linux-gnu.so
running build_scripts
creating build/scripts-3.5
copying ./src/test_PyCTP.py -> build/scripts-3.5
changing mode of build/scripts-3.5/test_PyCTP.py from 644 to 755
bixiang@bixiang-ThinkCentre-M8600t-N085:~/PyCTP$ cd build/
bixiang@bixiang-ThinkCentre-M8600t-N085:~/PyCTP/build$ ls
lib.linux-x86_64-3.5  scripts-3.5  temp.linux-x86_64-3.5
bixiang@bixiang-ThinkCentre-M8600t-N085:~/PyCTP/build$ cd scripts-3.5/
bixiang@bixiang-ThinkCentre-M8600t-N085:~/PyCTP/build/scripts-3.5$ ls
test_PyCTP.py
bixiang@bixiang-ThinkCentre-M8600t-N085:~/PyCTP/build/scripts-3.5$ 

@shizhuolin
Copy link
Owner

build/lib.linux-x86_64-3.5/PyCTP.cpython-35m-x86_64-linux-gnu.so 这是编译后的文件,直接放到项目根目录

@bixiang
Copy link
Author

bixiang commented Mar 26, 2018

我已经照做了,可是如何让其自动生成pyd文件呢?

Traceback (most recent call last):
  File "test_PyCTP.py", line 10, in <module>
    import PyCTP
ImportError: No module named 'PyCTP'

@shizhuolin
Copy link
Owner

在linux平台使用类似 PyCTP.cpython-35m-x86_64-linux-gnu.so 这样的文件(不可改文件名),把这个文件放到 test_PyCTP.py所在目录即可.
只有在windows平台才会生成并且使用PyCTP.pyd文件, 这是python在不同的平台差异.

@bixiang
Copy link
Author

bixiang commented Mar 26, 2018

移过去后要如何使用呢?因为仅仅就移过去,import PyCTP依然会报这个错呀

@shizhuolin
Copy link
Owner

需要将 v6.3.6_20160606_api_tradeapi_linux64 目录中的
libthosttraderapi.so, libthostmduserapi.so 文件也复制到 PyCTP.cpython-35m-x86_64-linux-gnu.so 和 *.py 同一个目录中. 原因是 PyCTP.cpython-35m-x86_64-linux-gnu.so 只是包装了功能,真正的执行其实还是由 api_tradeapi_linux64 完成.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants