Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Im making a simple game application using C++ and openGL for my uni.
Im trying to get a proper working environment at home and problems come up as i do this.
Some of them i have managed to sort out but others appear.
Now I am at the stage where I have installed eclipse, a compiler and downloaded glew and glut libraries. I believe i have liked them to eclipse as well but not 100% sure.
Well, I need someone whos relevant to guide me or tell me exactly what i need from scratch to start developing using OpenGL.
"Hello World" compiles and runs so im on the right path.
The other thing is that when i include glut and glew in my code, it used to underline them as it did not recognise them but now that's sorted as well. The underlining is gone (im guessing i did the linking right) but it won't compile because of this one error.
13:01:28 **** Incremental Build of configuration Debug for project second project ****
Building target: second project
Invoking: Cross G++ Linker
g++ -o "second project" ./src/second\ project.o -l/usr/include/GL
/bin/ld: cannot find -l/usr/include/GL
collect2: error: ld returned 1 exit status
make: *** [second project] Error 1
13:01:29 Build Finished (took 434ms)
Please I need help with this as I can't start working on the project.
If I made this post in the wrong forum, someone let me know asap!
Still, that also looks wrong, since libraries are not supposed to be in /usr/include, which naturally is for C header files. You need to find (probably with the locate utility) libGL.so, or some version of it. Whatever directory it is found in should be the argument to the -L compiler option.
*I installed eclipse 2 times. The first time using add/remove software application but installed the java version by accident (or it must have been the only eclipse i was seeing on the screen).
So I had to install the c++ version and so I did using terminal this time. I followed a simple guide on how to get it. Now i have 2 versions of eclipse, one (the first installation) that i can just run from the applications and the other (2nd installation c++) which is placed in /opt and doesnt come up in the applications screen. I can only run it from the folder.
Don't know if any of this is relevant but I thought of mentioning just in case.
No, you don't move them. You just use the appropriate compiler arguments to point to them. The '-l' (minus ell) argument tells the compiler/linker the name of a library to link. The '-L' argument tells the compiler/linker the name of a directory to add to its standard list of places to look for libraries.
BTW, when your compiler/Makefile says 'Cross G++ Linker', does that imply that you are building code for a non-native target architecture? Or does the word 'Cross' have some other meaning here? If you are doing cross development, that adds several levels of complexity. For cross development, you will need a full cross toolchain, as well as libraries for your target architecture. Usually, that means building those libraries, and installing them on the target host. If you are struggling with the basics like this, then you are really up against it, and have a lot of learning ahead. I would completely forget about using Eclipse in such an environment, as it will only add complexity that you don't need right now.
I have already spelled it out as simply as I can make it. In order to link with a particular library, the linker needs to be told to do so. This is done with the '-l' linker option. In your case, the library is libGL, so your compiler option would be '-lGL'. In order for the linker to know where the specified library lives in your filesystem, it has to be told, unless it is in one of the compilers standard places to look for libraries. The way you tell the linker where to look for libraries is with the '-L' option, which takes as an argument, the name of a filesystem directory. In your case, the directory of interest seems to be /usr/lib64, so your commandline argument to the linker also needs '-L /usr/lib64'.
There is nothing I can do to break it down any further than this. If something about this doesn't make sense, please tell me what it is.
I cannot give you a complete compiler commandline with knowing all of the files you are trying to compile &/or create. Please read what I have written; I've already answered the question of compiler access to libraries:
Ok basicaly I was trying to link the libs into eclipse without using the terminal.
I am getting my head around the problem finally.
There's only 1 source file that is to be compiled so far.
This is what i got:
$ gcc -lGL second.cpp -L /usr/lib64
/tmp/ccxJt9ub.o: In function `render()':
second.cpp:(.text+0x45): undefined reference to `glutSwapBuffers'
/tmp/ccxJt9ub.o: In function `main':
second.cpp:(.text+0x69): undefined reference to `glutInit'
second.cpp:(.text+0x73): undefined reference to `glutInitDisplayMode'
second.cpp:(.text+0x82): undefined reference to `glutInitWindowSize'
second.cpp:(.text+0x8c): undefined reference to `glutCreateWindow'
second.cpp:(.text+0x96): undefined reference to `glutIdleFunc'
second.cpp:(.text+0xa0): undefined reference to `glutDisplayFunc'
second.cpp:(.text+0xa5): undefined reference to `glewInit'
second.cpp:(.text+0xaa): undefined reference to `__GLEW_VERSION_2_0'
second.cpp:(.text+0x10e): undefined reference to `glutMainLoop'
collect2: error: ld returned 1 exit status
It's still giving me errors and I told it where to look, what else must be included ?
As I said before, if you don't already know what you're doing, using Eclipse just adds weight. Start out from first priniciples where you will learn what all of the Eclipse settings and configuration questions actually mean.
For your present problem, it looks like you need to add another library. Perhaps 'libglut'?
Add it to the same commandline as you did for libGL. If the library is in the same directory as libGL, then adding another '-L' option is not necessary.
# rpm -i freeglut-2.8.0-3.fc17.x86_64.rpm
package freeglut-2.8.0-7.fc17.x86_64 (which is newer than freeglut-2.8.0-3.fc17.x86_64) is already installed
file /usr/lib64/libglut.so.3.9.0 from install of freeglut-2.8.0-3.fc17.x86_64 conflicts with file from package freeglut-2.8.0-7.fc17.x86_64
However when i do this
gcc -lGL second.cpp -L /usr/lib64
i still get the same results...
Any ideas ?
The thing that confuses me the most is that while on eclipse, I went on project properties > C/C++ build > Settings and added /usr/include/GL (not /usr/lib64) to the libraries. After doing that, the underlining was gone (meaning it started to recognise the gl code). Anyway i will not bother with it for now, just pointing it out in case it helps to make sence.
You installed a package that we assume has a library containing the undefined references. Now you have to link to the library. First, you have to find it, so you can tell the linker where it is, just like you did for the first (libGL) library. You also have to tell the linker to use it, just like you did for the first library. I will assume the library is called libglut.so I don't know where it got installed; you will have to figure that out and modify the following accordingly.
or check how it is called. Be sure to have all the development libraries correctly installed. Do _NOT_ use the "rpm" command directly and do not install things without using repositories (for the former, there some exceptions). If you want to develop using a library, make sure the -devel is installed too. It probably wont solve your problem and you probably already did it, but I can't take it for granted reading the previous comments.