2017-05-27 47 views
0

我最近安装MinGW和CSFML我的笔记本电脑,我跑:未定义参考_imp_sfBlendAlpha

gcc shaders.c -csfml-system -csfml-graphics 

我得到一个错误:

...\ccV1NsAK.o:shaders.c:(.text+0x247):' undefined reference to _imp__sfBlendAlpha' 

我该如何解决这个问题?
亲切的问候, 波士顿布鲁克斯。


更新1
我已经安装到不同的搜索路径玩耍了,但我不能得到这个工作。我重新安装了MinGW并将CSFML包中的文件粘贴到默认路径。现在,我得到:

gcc shaders.c -lcsfml-system -lcsfml-window -lcsfml-graphics 
C:\Users\bbroo\AppData\Local\Temp\cc9QM4Nx.o:shaders.c:(.text+0x2d8): undefined reference to '_imp__sfBlendAlpha' 
C:\Users\bbroo\AppData\Local\Temp\cc9QM4Nx.o:shaders.c:(.text+0x318): undefined reference to '_imp__sfTransform_Identity' 
collect2.exe: error: ld returned 1 exit status 

更新2
我复制CSFML我的主文件夹。我得到:

$ gcc -B ~/CSFML -Ld: ~/CSFML shaders.c -lcsfml-system -lcsfml-window -lcsfml-graphics 
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find C:/MinGW/msys/1.0/home/bbroo/CSFML: Permission denied 
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lcsfml-system 
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lcsfml-window 
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32/bin/ld.exe: cannot find -lcsfml-graphics 
collect2.exe: error: ld returned 1 exit status 

头文件可以访问,但该点一个文件被“权限被拒绝” 如何设置权限为读 - 写 - 执行使用MSYS在CSFML在所有文件中的所有用户?

同样的问题,如果我使用C:\ SFML


更新3
当我将文件解压缩到默认路径,在文件夹中生成的子文件夹,我点一文件位于。它包含几个dot-a文件和一个自述文本文件。

本自述文件被复制到GCC-仅头文件 目录时会运行fixincludes通过的makefile GCC运行:

Many of the files in this directory were automatically edited from the standard system header files by the fixincludes process. They are system-specific, and will not work on any other kind of system. They are also not part of GCC. The reason we have to do this is because GCC requires ANSI C headers and many vendors supply ANSI-incompatible headers.

Because this is an automated process, sometimes headers get "fixed" that do not, strictly speaking, need a fix. As long as nothing is broken by the process, it is just an unfortunate collateral inconvenience. We would like to rectify it, if it is not "too inconvenient".


更新4
不链接编译工作得很好但单独链接不起作用:

[email protected] ~/Shaders 
$ ld shaders.o libcsfml-system.a libcsfml-window.a libcsfml-graphics.a 
shaders.o:shaders.c:(.text+0x10): undefined reference to `__main' 
shaders.o:shaders.c:(.text+0x2d8): undefined reference to `_imp__sfBlendAlpha' 
shaders.o:shaders.c:(.text+0x318): undefined reference to `_imp__sfTransform_Identity' 
shaders.o:shaders.c:(.text+0x4bc): undefined reference to `sleep' 

更新5
现在,我得到:

[email protected] ~/Shaders 
$ ld shaders.o libcsfml-system.a libcsfml-window.a libcsfml-graphics.a csfml-system-2.dll csfml-window-2.dll csfml-graphics-2.dll 
shaders.o:shaders.c:(.text+0x10): undefined reference to `__main' 
shaders.o:shaders.c:(.text+0x4bc): undefined reference to `sleep' 
+0

这是仅针对sfBlendAlpha吗?你可以尝试自己定义它,如[BlendMode](https://github.com/SFML/CSFML/blob/master/src/SFML/Graphics/BlendMode.cpp)所示。如果这是您第一次在代码中使用CSFML,那么可能是编译器没有找到您的库,特别是在这种情况下sfBlendAlpha。你在使用非标准路径吗?请描述你如何安装CSFML。 – Chringo

+0

我只是解压缩csfml包并将文件粘贴到默认路径。 –

回答

0

GCC shaders.c libcs​​fml-system.a libcs​​fml-window.a libcs​​fml-graphics.a csfml系统-2.DLL csfml窗口-2.DLL csfml-graphics-2.dll

作品

0

这似乎是一个链接错误。链接SFML库时您可能犯了一个错误。每个IDE链接库可能不同。

按照教程设置与您的IDE相匹配的SFML库。

+0

我找不到在MinGW上安装CSFML的任何教程。我只是将这些文件复制并粘贴到MinGW目录中,该目录过去一直适用于我。 –

+0

“由于它是一个C库,每个操作系统/体系结构只有一个归档文件,适用于任何编译器.Windows归档文件包含Visual C++和MinGW(gcc)的导入库;它们与相应编译器的每个版本兼容。 “所以我在csfml –

+0

上有正确的版本,我重新安装了MinGW和较早版本的CSFML。仍然是同样的问题。 –

0

在您的编译命令: gcc着色器。c -csfml-system -csfml-grphics

你可能会错过它(即-csfml-graphics)no?

+0

不,我只是在提问时写过。 –

0

这里有一个教程:https://www.sfml-dev.org/tutorials/2.4/start-cb.php

下连接部分截图,该教程提到3个库,需要链接中,这将转化为你需要在链接阶段添加命令行参数:

-lsfml-graphics -lsfml-window -lsfml-system 

您可能还需要告诉链接程序在哪里找到库,您需要根据它们在机器上的位置进行调整,例如

-LD:\ SMFL-2.0 \ lib中

+0

我将dot-a文件复制到\ lib并包含行-Ld \ lib但没有骰子。 –