鏈接到SDL2時出現ld錯誤


0

我正在努力用SDL2編譯c ++。我一如既往:

  1. 檢出代碼(來自mercurial和libsdl.org)
  2. ./ configure,make,sudo make install

但它總是要說:

/usr/bin/ld: error: cannot find -lSDL2

我需要快速處理源代碼,在13.04和13.10上,這些操作總是使我無法使用lib。現在回到12.04,正在發生一些奇怪的事情。另外,make安裝說明中還說:

Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR' 
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
 during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
 during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'

由於我似乎不明白,有人可以詳細說明這些說明嗎?

同時顯示兩個變量都表明它們為空,而且我使用的是64位版本的12.04(這很重要,因為在13.04 / 13.10上都沒有問題)

0

First, run:

$ ./configure

Then create a directory and go into it:

$ md build && cd ./build

Then run make:

$ ../make

Finally, install it:

$ sudo ../make install


0

You would want to install libsdl2-dev

sudo apt install libsdl2-dev

In order for your build tools to find the library to link against.