Author Topic: Manipulating the Compile Button, MinGW-W64 oddities  (Read 302 times)

Offline Geklmin

  • Single posting newcomer
  • *
  • Posts: 2
Manipulating the Compile Button, MinGW-W64 oddities
« on: August 15, 2017, 05:59:15 pm »
As many of you may know,  8) MinGW-w64 does NOT :'( play well with codeblocks. In fact, 8) MinGW-w64 has been really weird for me. It's forced me to do a lot of strange things... it won't even recognize any :o headers I place inside of the include directory. It won't even recognize  :-X LIBRARIES I put into the libraries directory. I have to put any and all :o headers and :-X libraries that didn't ship with the compiler into the same directory as my ??? source code... >:( very annoying, but I have learned to put up with it. :-\

However, I still want to use codeblocks with 8) MinGW-w64. My current solution has been to load up the cpp and c files in codeblocks, edit them there, and then to manually enter the compile command into the commandline. It works, and it works quite well. However, it is awfully tedious to have to open CMD, change directory to the 8) mingw-w64 projects folder, and paste the compile command into the command line. So... can I force the compile button in codeblocks to execute a specific line in the command prompt rather than trying to form one itself?

I would like codeblocks to run these 2 commands:
cd C:\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev1\mingw64\Projects_with_CodeBlocks\OpenGL
g++ -o myprogram.exe main.cpp -lmingw32 -lSDL2main -lSDL2 -lglew32s -lopengl32

Obviously, I can put them both in a batch file thus any number of lines of batch is really just one for codeblocks.




I'm sorry if this is in the wrong category, I did not feel like this belonged in help :P



-------------------------------------------------------
this signature is almost as fake as cnn

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5896
    • My Best Post
Re: Manipulating the Compile Button, MinGW-W64 oddities
« Reply #1 on: August 15, 2017, 06:13:30 pm »
Learn to use a real Code::Blocks project is my first guess of what you are doing wrong.

Post a full build log and maybe someone can guess what you are doing wrong.

http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sodev

  • Multiple posting newcomer
  • *
  • Posts: 95
Re: Manipulating the Compile Button, MinGW-W64 oddities
« Reply #2 on: August 15, 2017, 08:38:20 pm »
As many of you may know,  8) MinGW-w64 does NOT :'( play well with codeblocks.
Nope, thats new to me. I have compiled CodeBlocks itself with various MinGW-w64 editions multiple times with out-of-the-box settings without any problems.

Maybe you just need to set the proper path to your MinGW installation in CodeBlocks? And dont put your projects inside your MinGW installation, the MinGW installer won't like these additional directories.

Offline Geklmin

  • Single posting newcomer
  • *
  • Posts: 2
Re: Manipulating the Compile Button, MinGW-W64 oddities
« Reply #3 on: August 17, 2017, 12:45:05 am »
As many of you may know,  8) MinGW-w64 does NOT :'( play well with codeblocks.
Nope, thats new to me. I have compiled CodeBlocks itself with various MinGW-w64 editions multiple times with out-of-the-box settings without any problems.

Maybe you just need to set the proper path to your MinGW installation in CodeBlocks? And dont put your projects inside your MinGW installation, the MinGW installer won't like these additional directories.

MinGW-w64 won't see any libraries or headers I place inside of the installation folder/include or installation folder/libraries, and not only do I have to practice the disgusting habit of putting the include files directly inside my project folder (Forcing me to use quotes in my includes...), the -l (lowercase L not capital i) option has to be placed into the commandline to get libraries to even be recognized! Includes seem to work straight out of the working directory, though, so no specifications are needed for that.

I have properly set codeblocks to see my compiler's bin folder, and where the toolchain executables are and what they're called. I have no idea if I need to specify the include and library folders in codeblocks (In which case, how?)

Build logs just tell me that it didn't find the libraries, the headers, and of course goes on to say that all the functions in my program dependent on those resources don't exist.

I can paste one in, but it's exactly what you would expect. As stupid as it may sound, I've been working with MinGW and forks of it for a couple years now, and while I am certainly no expert (I learn things about it every time I use it) I know enough to tell you that the build log contains no further useful information.

Offline stahta01

  • Lives here!
  • ****
  • Posts: 5896
    • My Best Post
Re: Manipulating the Compile Button, MinGW-W64 oddities
« Reply #4 on: August 17, 2017, 01:28:24 am »
Build logs just tell me that it didn't find the libraries, the headers, and of course goes on to say that all the functions in my program dependent on those resources don't exist.

I can paste one in, but it's exactly what you would expect. As stupid as it may sound, I've been working with MinGW and forks of it for a couple years now, and while I am certainly no expert (I learn things about it every time I use it) I know enough to tell you that the build log contains no further useful information.

I do NOT believe you; I think you do NOT think you know how to understand the output of a full build log!

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Testing, compiling CB Trunk against wxWidgets 3.0.2.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline sodev

  • Multiple posting newcomer
  • *
  • Posts: 95
Re: Manipulating the Compile Button, MinGW-W64 oddities
« Reply #5 on: August 17, 2017, 08:58:18 am »
Im always amazed how people cant get things right in years but yet figure out how to do it in the most amazing ways wrong. And you top that by requesting a change in an IDE to support your totally bullshit approach ;D.

Well, where do i start? Dont put anything into your MinGW installation folder, especially not your projects!

Why doesn't MinGW find your headers and libraries? Because you didnt tell it where to look for them! You arent on linux where you can put this stuff into /usr/local/include and /usr/local/lib and it works, coding on windows is more difficult to prevent idiots to code even more useless crap :).

Why does it work in your projects folder? Because you turn it into your working directory by switching into it before compiling, and the working directory is the only one where MinGW searches for headers and libs by default!

So how to solve this problem? Use this wonderful -I switch to specify where to look for your headers. Use the amazing -L switch to specify where to look for your libraries. And since you are not using MSVC which supports autolinking you cant be saved from using tiny -l switches to specify which libs to link against.

And before you ask how to hack this into the compile button ... just set these paths in the proper locations in CodeBlocks!