ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
what about the include? what have you tried and what is the error (if any) you are receiving.
does this help
sorry man but i can't figure out how can i compile with gcc in that web site
a freind of mine said that i must find documentation about how to use gcc with that library
i mean i tape gcc ..........
i don't know what i tape there
i really think you should read the documentation on the g2 site to start with. post back logical and detailed results if you need more help, and good luck
i really think you should read the documentation on the g2 site to start with. post back logical and detailed results if you need more help, and good luck
i have read all the documentation of the g2 library but i don't figure out how to compile a program using that a library .
PS: my real problem is very simple just a code how to draw a line
When you compile a program that uses an external library (i.e. anything but glibc) you must do two things:
1. Include the header file and tell the compiler where look for the header file.
You use the #include directive in the code to pull the header file. The way you surround the filename determines where the compiler looks for it. If you surround the filename with <> (e.g. #include <g2.h>), the compiler looks in default locations (e.g. /usr/include, /usr/local/include). If you surround the filename in double quotes (e.g. #include "g2.h") the compiler looks in the local directory for the header file. You can add locations for the compiler to look for the header file on the compilation command line with the -I argument (e.g. gcc -I /home/user/develop/app/include -o my_app application.c)
2. You must inform the linker to incorporate the library into your program. This is only accomplished through the command line using the -l option. That's a lowercase L (not the number 1). For instance, if your program uses a function in the math library, you must tell the linker to incorporate the math library on the command line. The math library filename is libm.so and it's located in a standard library location (such as /usr/lib, /usr/local/lib). You tell the linker to do this with the -l argument (e.g. gcc -lm -o my_app application.c). Assuming the g2 library you're using is named libg2.so, the compilation command line would use -lg2. The -L argument can be used to add other directories to search for the library file if the library is not installed in a standard location.
Lastly, it should be pointed out that some well-designed software packages utilize the pkg-config utility. The pkg-config utility tells you, the developer, what arguments are necessary to the compiler to use the library. For instance, pkg-config --cflags g2 would return the compiler arguments to perform the initial object code creation. Running pkg-config --libs g2 would give the compiler arguments necessary to link the program with the library. You can combine the two if you want to get all the arguments necessary to compile and link in one command (pkg-config --cflags --libs g2). This will work only if the g2 library supports the pkg-config utility and g2 was installed in standard location so that pkg-config can find the files it needs. Otherwise, you need to figure out the command line arguments manually (through documentation or your own investigation).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.