Author Topic: Adding compiler/linker flags to the end  (Read 339 times)

Offline backes

  • Single posting newcomer
  • *
  • Posts: 3
Adding compiler/linker flags to the end
« on: January 19, 2018, 12:18:53 pm »
Hello,

I'm using Code::Blocks 16.01 on Fedora. I need to link Eigen and MathGL. The makefile would look like:
Code: [Select]
g++ -std=gnu++11 -o3 -march=native -I /usr/include/ -I /usr/include/eigen3/ -c ... -o ... -lmgl
After a bit of searching the web I was able to setup the compiler in code::blocks to have all the includes and flags I want. The only missing part is the -lmgl flag. When I add it under "Compiler Settings" -> "Other Compiler Options" it gets added right after the g++ (e.g. g++ -myflag -std=gnu++11 ...) When I add it in "Linker settings" -> "Other linker options" it doesn't appear at all in the build log and the program won't compile.

Is there a way to add this -lmgl linker flag at the end of the build command or do I have to use make?

Thank you,
backes


/edit: And the security question for the forum is wrong as we're already 2018

Online stahta01

  • Lives here!
  • ****
  • Posts: 6195
    • My Best Post
Re: Adding compiler/linker flags to the end
« Reply #1 on: January 19, 2018, 01:11:01 pm »
Did you try adding mgl to the library list under the "Linker settings"?

If that fails, post a build log of the failure.
http://wiki.codeblocks.org/index.php/FAQ-Compiling_(errors)#Q:_How_do_I_troubleshoot_a_compiler_problem.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 backes

  • Single posting newcomer
  • *
  • Posts: 3
Re: Adding compiler/linker flags to the end
« Reply #2 on: January 19, 2018, 01:26:23 pm »
Hello,

Thank you for your reply. I had another look at the Build log and saw that one error suggested to use gnu++11. As I set the -std=c++11 flag already and thought they were equivalent I assumed that the problem was in the missing -lmgl flag. I just found out, that c++11 and gnu++11 are in fact not the same, and the problem got resolved with the gnu++11 flag (instead of c++11). Now the second line in the build log includes the -lmgl flag and everything is compiling and linking flawlessly.

As a side note, I can't add mathgl to the library list because it's not a compiled library but consists only of header files. Giving the compiler the search path works.

Thank you,
backes