Cannot link the header file using gcc linker in windows

Viewed 25

hello.c will use the header file plugin.h. If I want to use gcc to compile, can I know how should I write the -LXXX. gcc -o hello hello.c -LXXX

Currently my project structure look like this project directory is (C:\project) project

  • examples/ hello.c
  • include / plugins/ plugin.h
1 Answers

You don't link the header file, you include it. You link object files and static/shared libraries, which are already compiled files.

But to answer your question, you include your plugin with the -I option.

g++ -O2 examples/hello.c -I include/plugins -o hello

Or if you have a library to link say in lib:

g++ -O2 examples/hello.c -I include/plugins -L lib/plugins -lplugin -o hello

Or if you want to do in two steps (notice the -c)

g++ -O2 -c examples/hello.c -I include/plugins -o hello.o
g++ hello.o -L lib/plugins -lplugin -o hello
Related