首先是header file的链接,sdl .h文件默认装在/usr/include/SDL/ 下,lib还好,都在stantared lib directory下,不过我也是现在才知道的哈。
#include"SDL/SDL.h",而不是直接“SDL.h"。另外在编译包含了"rotozoom.h"时,用gcc -Wall sdl.c -lSDL -lmingw32 -lSDLmain
仍然会提示错误undefined reference to rotozoomSurface funcion,我google来了好久,终于无意中发觉了错误在哪里。rotozoom.h是SDL_gfx的头文件,加上-lSDL_gfx就行了。百度,google上在gcc linker上卡住的programmers比比皆是,新手老手都有。这里有一篇文章讲libs的链接,很详细,研究下,就对函数库了解多一些了。
Search path example</a></h3>
The following example program uses a library that might be installed as an additional package on a system--the GNU Database Management Library (GDBM). The GDBM Library stores key-value pairs in a DBM file, a type of data file which allows values to be stored and indexed by a key</i> (an arbitrary sequence of characters). Here is the example program ‘dbmain.c’</tt>, which creates a DBM file containing a key ‘testkey’</samp> with the value ‘testvalue’</samp>: </p>
#include #include int main (void) { GDBM_FILE dbf; datum key = { "testkey", 7 }; /* key, length */ datum value = { "testvalue", 9 }; /* value, length */ printf ("Storing key-value pair... "); dbf = gdbm_open ("test", 0, GDBM_NEWDB, 0644, 0); gdbm_store (dbf, key, value, GDBM_INSERT); gdbm_close (dbf); printf ("done.n"); return 0; } </pre>
The program uses the header file </span>‘gdbm.h’</tt> and the library </span>‘libgdbm.a’</tt>. If the library has been installed in the default location of </span>‘/usr/local/lib’</tt>, with the header file in </span>‘/usr/local/include’</tt>, then the program can be compiled with the following simple command: </span></p>
$ gcc -Wall dbmain.c -lgdbm </pre>
Both these directories are part of the default gcc</code> include and link paths. </p>
However, if GDBM has been installed in a different location, trying to compile the program will give the following error: </p>
$ gcc -Wall dbmain.c -lgdbm dbmain.c:1: gdbm.h: No such file or directory </pre>
For example, if version 1.8.3 of the GDBM package is installed under the directory ‘/opt/gdbm-1.8.3’</tt> the location of the header file would be, </p>
/opt/gdbm-1.8.3/include/gdbm.h </pre>
which is not part of the default gcc</code> include path. Adding the appropriate directory to the include path with the command-line option -I</code> allows the program to be compiled, but not linked: </p>
$ gcc -Wall -I/opt/gdbm-1.8.3/include dbmain.c -lgdbm /usr/bin/ld: cannot find -lgdbm collect2: ld returned 1 exit status </pre>
The directory containing the library is still missing from the link path. It can be added to the link path using the following option: </p>
-L/opt/gdbm-1.8.3/lib/ </pre>
The following command line allows the program to be compiled and linked: </p>
$ gcc -Wall -I/opt/gdbm-1.8.3/include -L/opt/gdbm-1.8.3/lib dbmain.c -lgdbm </pre>
This produces the final executable linked to the GDBM library. Before seeing how to run this executable we will take a brief look at the environment variables that affect the -I</code> and -L</code> options. </p>
Note that you should never place the absolute paths of header files in #include</code> statements in your source code, as this will prevent the program from compiling on other systems. The -I</code> option or the INCLUDE_PATH</code> variable described below should always be used to set the include path for header files. </p></div>
#include#include int main (void) { GDBM_FILE dbf; datum key = { "testkey", 7 }; /* key, length */ datum value = { "testvalue", 9 }; /* value, length */ printf ("Storing key-value pair... "); dbf = gdbm_open ("test", 0, GDBM_NEWDB, 0644, 0); gdbm_store (dbf, key, value, GDBM_INSERT); gdbm_close (dbf); printf ("done.n"); return 0; } </pre> The program uses the header file </span>‘gdbm.h’</tt> and the library </span>‘libgdbm.a’</tt>. If the library has been installed in the default location of </span>‘/usr/local/lib’</tt>, with the header file in </span>‘/usr/local/include’</tt>, then the program can be compiled with the following simple command: </span></p>
$ gcc -Wall dbmain.c -lgdbm </pre>Both these directories are part of the default
gcc</code> include and link paths. </p>However, if GDBM has been installed in a different location, trying to compile the program will give the following error: </p>
$ gcc -Wall dbmain.c -lgdbm dbmain.c:1: gdbm.h: No such file or directory </pre>For example, if version 1.8.3 of the GDBM package is installed under the directory ‘/opt/gdbm-1.8.3’</tt> the location of the header file would be, </p>
/opt/gdbm-1.8.3/include/gdbm.h </pre>which is not part of the default
gcc</code> include path. Adding the appropriate directory to the include path with the command-line option-I</code> allows the program to be compiled, but not linked: </p>$ gcc -Wall -I/opt/gdbm-1.8.3/include dbmain.c -lgdbm /usr/bin/ld: cannot find -lgdbm collect2: ld returned 1 exit status </pre>The directory containing the library is still missing from the link path. It can be added to the link path using the following option: </p>
-L/opt/gdbm-1.8.3/lib/ </pre>The following command line allows the program to be compiled and linked: </p>
$ gcc -Wall -I/opt/gdbm-1.8.3/include -L/opt/gdbm-1.8.3/lib dbmain.c -lgdbm </pre>This produces the final executable linked to the GDBM library. Before seeing how to run this executable we will take a brief look at the environment variables that affect the
-I</code> and-L</code> options. </p>Note that you should never place the absolute paths of header files in
#include</code> statements in your source code, as this will prevent the program from compiling on other systems. The-I</code> option or theINCLUDE_PATH</code> variable described below should always be used to set the include path for header files. </p></div>
分析预测模型在机器学习中的应用之线性回归
回归能做任何事情 Continue reading