SCONS:LD找不到标准库

发布于 2025-02-13 22:01:04 字数 1783 浏览 1 评论 0原文

我正在与Raylib一起使用SCONS进行建筑。我正在使用clang将编译从Ubuntu(In WSL)交叉到Windows。我的项目目录包含带有raylib二进制文件的lib目录,include与Raylib标头的目录。当我运行SCONS时,我将获得此输出:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
clang++ -o main.o -c -mwindows --target=x86_64-w64-windows-gnu -static -static-libgcc -static-libstdc++ -Iinclude main.cpp
clang: warning: argument unused during compilation: '-mwindows' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-static-libgcc' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-static-libstdc++' [-Wunused-command-line-argument]
clang++ -o tiled_test.exe main.o -Llib -lraylib -lopengl32 -lgdi32 -lwinmm
/bin/ld: cannot find -lopengl32
/bin/ld: cannot find -lgdi32
/bin/ld: cannot find -lwinmm
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [tiled_test.exe] Error 1
scons: building terminated because of errors.

ld找不到OpenGL32gli32winmm

我的sconstruct文件:

import os

LIBS=['raylib', 'opengl32', 'gdi32', 'winmm']
LIBPATH='./lib'
CCFLAGS='-mwindows --target=x86_64-w64-windows-gnu -static -static-libgcc -static-libstdc++'

env = Environment(CXX='clang++', CPPPATH='./include')
env['ENV']['TERM'] = os.environ['TERM'] # Colored output

env.Program('tiled_test.exe', 'main.cpp', LIBS=LIBS, LIBPATH=LIBPATH, CCFLAGS=CCFLAGS)

直接运行clang ++时,它可以很好地工作。

clang++ main.cpp -o tiled_test.exe -Iinclude -Llib -mwindows --target=x86_64-w64-windows-gnu -static -static-libgcc -static-libstdc++ -lraylib -lopengl32 -lgdi32 -lwinmm

I'm developing a game with raylib using SCons for building. I'm using Clang to cross compile from Ubuntu (in WSL) to Windows. My project directory contains a lib directory with the raylib binaries and an include directory with the raylib headers. When I run SCons I get this output:

scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
clang++ -o main.o -c -mwindows --target=x86_64-w64-windows-gnu -static -static-libgcc -static-libstdc++ -Iinclude main.cpp
clang: warning: argument unused during compilation: '-mwindows' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-static-libgcc' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-static-libstdc++' [-Wunused-command-line-argument]
clang++ -o tiled_test.exe main.o -Llib -lraylib -lopengl32 -lgdi32 -lwinmm
/bin/ld: cannot find -lopengl32
/bin/ld: cannot find -lgdi32
/bin/ld: cannot find -lwinmm
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [tiled_test.exe] Error 1
scons: building terminated because of errors.

ld can't find opengl32, gli32, and winmm.

My SConstruct file:

import os

LIBS=['raylib', 'opengl32', 'gdi32', 'winmm']
LIBPATH='./lib'
CCFLAGS='-mwindows --target=x86_64-w64-windows-gnu -static -static-libgcc -static-libstdc++'

env = Environment(CXX='clang++', CPPPATH='./include')
env['ENV']['TERM'] = os.environ['TERM'] # Colored output

env.Program('tiled_test.exe', 'main.cpp', LIBS=LIBS, LIBPATH=LIBPATH, CCFLAGS=CCFLAGS)

When I run Clang++ directly it works perfectly.

clang++ main.cpp -o tiled_test.exe -Iinclude -Llib -mwindows --target=x86_64-w64-windows-gnu -static -static-libgcc -static-libstdc++ -lraylib -lopengl32 -lgdi32 -lwinmm

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七堇年 2025-02-20 22:01:05

我找到了我问题的答案。根据 this 默认情况下,SCONS不使用Shell的PATH。用户需要将其添加到环境中。

我固定的sconstruct文件:

import os

LIBS=['raylib', 'opengl32', 'gdi32', 'winmm']
LIBPATH='./lib'
CCFLAGS='-static --target=x86_64-w64-windows-gnu'
LINKFLAGS = '-mwindows --target=x86_64-w64-windows-gnu -static-libgcc -static-libstdc++'

env = Environment(CXX='clang++', CPPPATH='./include', tools = ['mingw'], ENV = {'PATH' : os.environ['PATH']})
env['ENV']['TERM'] = os.environ['TERM'] # Colored output

env.Program('tiled_test.exe', 'main.cpp', LIBS=LIBS, LIBPATH=LIBPATH, CCFLAGS=CCFLAGS, LINKFLAGS=LINKFLAGS)

I found the answer to my problem. According the this by default SCons doesn't use the shell's PATH. The user needs to add it to the environment.

My fixed SConstruct file:

import os

LIBS=['raylib', 'opengl32', 'gdi32', 'winmm']
LIBPATH='./lib'
CCFLAGS='-static --target=x86_64-w64-windows-gnu'
LINKFLAGS = '-mwindows --target=x86_64-w64-windows-gnu -static-libgcc -static-libstdc++'

env = Environment(CXX='clang++', CPPPATH='./include', tools = ['mingw'], ENV = {'PATH' : os.environ['PATH']})
env['ENV']['TERM'] = os.environ['TERM'] # Colored output

env.Program('tiled_test.exe', 'main.cpp', LIBS=LIBS, LIBPATH=LIBPATH, CCFLAGS=CCFLAGS, LINKFLAGS=LINKFLAGS)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文