简体   繁体   中英

How to let gcc compiler know where a certain file is

I'm trying to compile my C code but I need to tell the GCC compiler where two file are.

The two files are located here

/usr/local/ssl/include/
/usr/local/ssl/lib/

I want to add this to my gcc -o file file.c so that my program can work.

In gcc, the -I option is used for adding a directory to the set of directories to search for header files, and the -L option is used for adding a directory to the set of directories to search for libraries. Since you're not explicitly linking in any libraries, you shouldn't need the -L option in this case.

gcc -I/usr/local/ssl/include -o file file.c

If you were linking in libraries, something like the following format should work, assuming that file.c calls a function in libmyLib.a :

gcc -I/usr/local/ssl/include -o file file.c -L/path/to/my/library -lmyLib

See this question for more details regarding library linking order.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM