Search code examples
c++openglgcccodeblocksglew

Do GNU GCC compilers only accept "<filename>.a" files as libraries?


So, basically what I am asking is, if GNU GCC compilers recognize only ".a" files as library files, the reason why I am asking this is because, I have linked 3 library files in my codeblocks cpp project, two of the library files have ".a" extension, the last has a ".lib" extension. When I try to build the project, this is this the error I get:

-------------- Build: Debug in OpenGl_GLFW (compiler: GNU GCC Compiler)---------------

g++.exe -Wall -g -Idependencies\include -Idependencies\include
-IC:\Users\Mubarak\Documents\Programming\Cpp\OpenGl_GLFW\dependencies\include -c C:\Users\Mubarak\Documents\Programming\Cpp\OpenGl_GLFW\dependencies\lib\glew32s.lib -o obj\Debug\dependencies\lib\glew32s.o
g++.exe -Ldependencies\lib -Ldependencies\lib -LC:\Users\Mubarak\Documents\Programming\Cpp\OpenGl_GLFW\dependencies\lib -o bin\Debug\OpenGl_GLFW.exe obj\Debug\dependencies\lib\glew32s.o dependencies\lib\libglfw3.a dependencies\lib\libglfw3dll.a obj\Debug\src\main.o   -lopengl32.a dependencies\lib\glew32s.lib dependencies\lib\libglfw3.a -lopengl32.a dependencies\lib\glew32s.lib dependencies\lib\libglfw3.a
g++.exe: warning: C:\Users\Mubarak\Documents\Programming\Cpp\OpenGl_GLFW\dependencies\lib\glew32s.lib:
linker input file unused because linking not done
g++.exe: error: obj\Debug\dependencies\lib\glew32s.o: No such file or directory
Process terminated with status 1 (0 minute(s), 0 second(s)) 1
error(s), 1 warning(s) (0 minute(s), 0 second(s))

so it looks like there is trouble with the .lib library file, I started programming in visual studio Community, over there, the .lib file works............. so am starting to get a sense "library files only work with a particular compiler if the same compiler was responsible for creating them" i just want to be sure of this.

If so, why do different compilers produce library files with different extensions ? And, do different compilers compile differently ? do different compilers create different machine code ?


Solution

  • the .lib is presumably a visual studio static library which wont work with gcc anyway

    found this in one of the comments, which means, visual studio used .lib libraries and gcc uses .a libraries