Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: alt + 255 on November 05, 2017, 03:38:35 pm

Title: Code::Blocks try to open .obj libs, but not .lib?
Post by: alt + 255 on November 05, 2017, 03:38:35 pm
(in first, I'm french so this not will be a perfect english)

Hi,
I've tried to configure the visual studio compiler for code::blocks, and after a few try, I have edited some .xml files in the code::blocks folder, now everything works except one thing : when I build my project, the compiler say "can't find library_name.obj". The problem is that every of my libraries have a .lib extention, and in the parameters, and the .xml files, it seems to have ".obj" nowhere so... Can you explain to me why code::blocks adds ".obj" at the end of my libraries ? I will try to change this after understanding

Thanks for help me
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: oBFusCATed on November 05, 2017, 07:08:17 pm
*.obj is an object file. It is produced by compiling source files. They are not containing libraries.

So if you're getting library_name.obj then you have a library_name.cpp in your project.
For more information read this:
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.3F
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: sodev on November 05, 2017, 07:39:03 pm
There is no need to edit any XML file to use msvc compiler with CodeBlocks. You probably messed up something real good now, you better revert your changes.

The Visual Studio 2010 compiler template of CodeBlocks is a good start, if you are using a newer version you have to adjust some paths and add some options, there should be a post from me somewhere here on the forum explaining the setup, i just cant dig it up currently, small screen and keyboard on cell phone (lame excuses, im lazy ;D)
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: alt + 255 on November 05, 2017, 07:49:52 pm
I know how to use the MSVC compiler with code::blocks, but there was a problem with the resource compiler, I just edited the resource compiler line on .xml files.
And the problem is not that I have .obj files, the problem is that code::blocks search the .obj files, but I want it to search .lib files, and I don't know how...
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: oBFusCATed on November 05, 2017, 08:07:02 pm
Then post a patch with your changes, so more people could benefit from them.
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: alt + 255 on November 05, 2017, 11:57:01 pm
First time I create a patch, I hope it will work... (it's for windows)
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: cacb on November 06, 2017, 09:36:17 am
There is no need to edit any XML file to use msvc compiler with CodeBlocks. You probably messed up something real good now, you better revert your changes.

This is wrong and misleading. The Code::Blocks configuration files & project files are indeed XML files. There is also GUI for editing configurations, but it is stored as XML.

I also use Code::Blocks with MSVC (currently MSVC2013). Attached is a summary of my setup for MSVC2013 using Code::Blocks global variables. I use a generic "MSVC" compiler in all my projects and just change the global variables when changing MSVC version. The names of the global variables are somewhat logical, but not 100%, but this setup works.
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: alt + 255 on November 06, 2017, 11:34:18 am
Hum, everyone, this is cool that you try to help me, but you complicate the problem : my msvc compiler work (my configuration is similar to the configuration of cacb), the problem is just Code::Blocks (or I don't know what) who search a bad extention, this is probably just a parameter in an obscure menu, or a line in another .xml file...
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: sodev on November 06, 2017, 01:23:51 pm
Post a full build log, im pretty sure its just a configuration error.
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: alt + 255 on November 06, 2017, 04:22:08 pm
Here is the full build log :

Code: html
-------------- Clean: Release in fil (compiler: Visual Studio 2017 compiler)---------------

Cleaned "fil - Release"

-------------- Build: Release in fil (compiler: Visual Studio 2017 compiler)---------------

[ 33.3%] cl.exe /nologo /EHsc /Ox -O2 -O2 /FS /DGLEW_STATIC /DSFML_STATIC /DWIN32 /D__GNUWIN32__ /DUNICODE -DGLEW_STATIC -DSFML_STATIC -DWIN32 -D__GNUWIN32__ -DUNICODE -IG:\WorkspaceC++\Bibliotheques\SFML-2.4.2\include -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" -I"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include" /c C:\FourreTout\Syssy\TestFilGravite\prog\main.cpp /Fo.objsR\main.cpp.obj
[ 66.7%] rc.exe -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\shared" -I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt" -I"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\include" -fo.objsR\resources.rc.res C:\FOURRE~1\Syssy\TESTFI~1\prog\RESOUR~1.RC
[100.0%] link.exe          /nologo /subsystem:windows /LIBPATH:G:\WorkspaceC++\Bibliotheques\SFML-2.4.2\lib /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\ucrt\x86" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.15063.0\um\x86" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.11.25503\lib\x86" /out:..\fil.exe    sfml-main sfml-system-s sfml-window-s sfml-network-s sfml-graphics-s sfml-audio-s openal32 jpeg freetype ws2_32 gdi32 opengl32 winmm FLAC ogg vorbis vorbisenc vorbisfile .objsR\main.cpp.obj  .objsR\resources.rc.res
main.cpp
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.
LINK : fatal error LNK1181: impossible d'ouvrir le fichier en entrée 'sfml-main.obj'
Process terminated with status 1181 (0 minute(s), 1 second(s))
0 error(s), 0 warning(s) (0 minute(s), 1 second(s))
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: sodev on November 06, 2017, 07:15:19 pm
The lib extension doesn't get added to the libraries so the linker thinks they are object files. Two reasons for this come into my mind.

Open the Build Options of your project, select the corresponding configuration and check the Linker Settings, have you specified the Link Libraries without prefix and extensions, e.g. the entries look like sfml-main?

Menu Settings -> Compiler -> (Select your compiler in the combobox) -> Tab Other settings -> Button Advanced Options -> Tab Others
- Textfield Library extension should contain: lib
- Checkbox Linker needs lib extension should be: checked

In your log i see a custom compiler name, i assume you created an own compiler entry, what compiler entry did you copy to create it? Because your include specifications look like gcc. Better copy the Visual Studio 2010 entry, it already contains all the proper settings, you just have to fix the paths (and add the /FS option to get parallel builds to work).
Title: Re: Code::Blocks try to open .obj libs, but not .lib?
Post by: alt + 255 on November 07, 2017, 01:43:43 pm
Okay, it was just this little checkbox, and now it works !

Thanks everyone