Author Topic: Mixing C and C++ code linker option  (Read 4982 times)

Offline stefanofranzoni

  • Single posting newcomer
  • *
  • Posts: 2
Mixing C and C++ code linker option
« on: July 19, 2021, 03:17:10 pm »
My project contains C code and uses an external library written in C++.
The linker is normally g++ but on an Ubuntu 20.04 installation he automatic linker choice is gcc and it generates many errors.
I don't find an option to force the linker to g++ while keeping the compiler to gcc.

Thanks in advance
Stefano Franzoni

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Mixing C and C++ code linker option
« Reply #1 on: July 19, 2021, 03:25:02 pm »
CB Version info is needed; the option below is less than 3 years old IIRC.

CB Version SVN 12452

Project -> Build Options
Tab: Linker Settings
Linker Executable: "Auto Detect" likely needs changed to "Use C++ Compiler"

Tim S.

C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stefanofranzoni

  • Single posting newcomer
  • *
  • Posts: 2
Re: Mixing C and C++ code linker option
« Reply #2 on: July 19, 2021, 04:09:56 pm »
Tim, thanks for your reply.

My version of Codeblocks is 20.03.

Your suggestion solves my problem.

I noticed however that it is not necessary to add "Use C ++ compiler" in the linker options when using Codeblocks as administrator ie running "sudo Codeblocks".

The problem is reproducible with two simple files, one in C and the other in C ++.

Stefano