本文介绍了SFML 2.1架构x86_64错误的未定义符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了SFML 2.1,并尝试从终端编译和运行,而不是Xcode,他们在他们的网站上的示例程序。

I have recently installed SFML 2.1 and am trying to compile and run from the terminal, NOT Xcode, the sample program that they have on their website at http://www.sfml-dev.org/tutorials/2.0/start-linux.php.

   Path to where I installed SFML:
   /Users/brendanbusey/Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal

但是,我一直收到以下错误:

However, I keep getting the error of:

   Undefined symbols for architecture x86_64:
   "sf::String::String(char const*, std::__1::locale const&)", referenced from:
  _main in window-48cb4a.o

在google之后,我遇到了这个问题:

After googling it, I came across this question: SFML 2.1 RenderWindow linking error

在接受的答案,人说如果我想使用g ++,我不得不下载GCC版本。所以,我继续下载GCC - 通用32 + 64位(OS X 10.5+)版本,然后按照说明在linux上安装和编译SFML,因为没有mac()通过执行以下操作:

In the accepted answer, the person said that if I wanted to use g++, I had to download the "GCC" version. So, I proceeded to download the GCC - universal 32+64 bits (OS X 10.5+) version and then followed the instructions for installing and compiling SFML on linux, since there were none for mac (http://www.sfml-dev.org/tutorials/2.0/start-linux.php) by doing the following:

由于我在非标准位置安装了SFML,我告诉我的编译器在哪里找到头文件,如:

Since I had installed SFML in a non-standard location, I told my compiler where to find the header files like so:

   -I /Users/brendanbusey/Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/Frameworks/SFML.framework/Headers

我还必须告诉我的编译器在哪里找到SMFL库:

I also had to tell my compiler where to find the SMFL libraries:

  -L /Users/brendanbusey/Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib

我还需要告诉库加载器从哪里找到SFML库:

I needed to also tell the library loader where to find the SFML libraries from:

  export LD_LIBRARY_PATH=/Users/brendanbusey/Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib

然后,我把sfml-audio.framework,sfml-window.framework,sfml-graphics.framework,sfml-network.framework ,和我的框架目录(/ Library / Frameworks)中的sfml-system.framework。

Then, I put the sfml-audio.framework, sfml-window.framework, sfml-graphics.framework, sfml-network.framework, and sfml-system.framework in my Frameworks directory (/Library/Frameworks).

最后,我试图以下列方式编译我的程序:

Finally, I tried to compile my program in the following ways:


  1. g ++ window.cpp -I /Users/brendanbusey/Desktop/C++_Code/SMFL/SFML-2.1 -osx-gcc-universal / Frameworks / SFML.framework / Headers / SFML -L /users/brendanbusey/Desktop/C++_Code/SMFL/SFML-2.1-osx-gcc-universal/lib -framework sfml-graphics -framework sfml-window -framework sfml-system

g ++ window.cpp -framework sfml-graphics -framework sfml-window -framework sfml-system

。我继续google的错误,但我所得到的是人们使用Xcode而不是终端的问题。任何帮助将非常感谢!

But, I keep getting the same error. I have continued to google the error, but all I keep getting are questions where people are using Xcode and not the terminal. Any help would be greatly appreciated!

推荐答案

我想出来了!首先,正如Joachim Pileborg指出的,我需要安装clang版本的SFML for mac,因为我使用g ++来编译它是伪装的clang ++,正如Joachim Pileborg也指出的。接下来,我必须再次阅读有关在Linux中设置SFML的说明()。

I figured it out at last! First off, as Joachim Pileborg pointed out, I need to install the clang version of SFML for mac since I was using g++ to compile which is clang++ in disguise, as Joachim Pileborg also pointed out. Next, I had to go through the instructions again for setting up SFML with Linux (http://www.sfml-dev.org/tutorials/2.0/start-linux.php).

但是,蛋糕上的结冰是当我阅读这个问题:

However, the icing on the cake was when I read this question:

...和这个问题:

...这让我想:也许我应该尝试移动我的freetype.framework文件夹(可以在extlibs目录中找到)放入我的/ Library / Frameworks目录。一旦我这样做和编译使用

...which got me thinking: maybe I should try moving my freetype.framework folder (which can be found in the extlibs directory) into my /Library/Frameworks directory. Once I did this and compiled using

g++ window.cpp -framework sfml-graphics -framework sfml-window -framework sfml-system

它编译并运行成功!我现在很高兴!

It compiled and ran successfully!!! I am very happy now!

这篇关于SFML 2.1架构x86_64错误的未定义符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 20:47