c++ - 关于编译cpp文件

浏览:29日期:2023-05-12

问题描述

下载了cocos2dxv3.1的然后要把几个cpp文件编译成so库 怎么在命令行中编译啊 第一次生成so不知道该怎么写 需要哪些文件 知道的麻烦告诉下可以吗

问题解答

回答1:

假设你用的是gcc或者clang,那么大概可以分为两个步骤:

1.编译.cpp文件:

g++ $(CPPFLAGS) -c example1.cpp -o example1.og++ $(CPPFLAGS) -c example2.cpp -o example2.o

2.生成.so文件:

g++ -shared example1.o example2.o -o libexample.so

相关文章: