c++ - makefile 为不同的体系结构设置不同的链接器标志

标签 c++ gcc makefile linker


我想要一个 make 文件在 Windows 上编译和链接(到 mylib.dll)和至少两个 Linux 架构,i686 和 armv61(到 mylib.so)。

如果我手动“设置”链接器标志,我的代码可以编译/链接。

但我想根据某些 ARC 值设置链接器标志,请参阅代码片段。

<code>
ARCH = "?"
ARCH = $(shell arch)
$(info ARCH  is [$(ARCH)])
LD_FLAGS = "?"
ifeq  "$(ARCH)" "i686"
LD_FLAGS = -shared -lSDL
endif
ifeq  "$(ARCH)" "armv61"
LD_FLAGS = -shared -lSDL -L/usr/lib/arm-linux-gnueabihf 
endif
$(info LD_FLAGS is [$(LD_FLAGS)])
</code>

在我的 i686 上我得到:

<code>
ARCH  is [i686]
LD_FLAGS is [-shared -lSDL]
make: Nothing to be done for 'all'.
</code>

在我的 armv61 上我得到:

<code>
ARCH  is [armv6l]
LD_FLAGS is ["?"]
... (error stuff!)
</code>

所以 ARCH 设置正常但 LD_FLAGS 不是,我正在用 ifeq 等做一些愚蠢的事情。

知道错误是什么,如何修复 make 文件?

谢谢。

最佳答案

你写了一个1而不是l(armv6l vs armv61)

关于c++ - makefile 为不同的体系结构设置不同的链接器标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43259249/

相关文章:

c++ - SDL MinGW Netbeans。 <SDL/SDL.h> 没有那个文件或目录

c++ - 具有现有变量的基于范围的 for 循环

c - 将 GCC 扩展与使用 clang 编译的代码一起使用?

makefile - 使-j RAM限制

c++ - 定义的改变

c++ 如何在不进行深度复制的情况下展平 xtensor 的 View ?

c++ - 检查类是否可流式传输的概念

c - 添加编译阶段

c++ - 使用 Makefile 和 GTest 对函数的 undefined reference

ios - “strcmp”未在此范围内声明