Author Topic: How to create windows C dll using project wizard (No option for C, only C++)  (Read 3841 times)

Offline Michaela Joy

  • Multiple posting newcomer
  • *
  • Posts: 11
Hi,
I would like to build a C dll for Windows using tdm-gcc w64 and code::blocks. However, when I create a new project using the wizard, there is no option to specify whether the DLL is C or C++.
So, I get a C++ dll project ever time. I went looking around in the various settings and have not found any way to change this (tdm-gcc g++ is used as the compiler)

I'm using code::blocks 13.12

Thanks in advance,
:MJ

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
Not tested.

1. Save the generated C++ file with an file extension of ".c".
2. Add the saved file to the project.
3. Remove the C++ file from the project.

Then build the project.

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 Michaela Joy

  • Multiple posting newcomer
  • *
  • Posts: 11
@stahta01: Thanks for replying.

As you suggested, I created a new DLL project called test, and added a new C source file to it, following your instructions.

It used gcc to compile, but it uses g++ to link.

To be honest, I don't know enough about the toolset to know whether or not this will make a difference in the DLL.

I'm going to build a more complex test and see.

:MJ

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7591
    • My Best Post
It used gcc to compile, but it uses g++ to link.

I have no idea if linking with g++ will or will NOT cause an issue.

To make it link using gcc instead of g++ you have two simple options.
1. Edit the GCC toolchain setting by changing the command used to link. (this means you can no longer compile C++ code using this compiler)

2. Copy the GCC toolchain and then edit the new compiler settings.
(Remember to change the CB project to using the new toolchain/compiler)

Tim S.
« Last Edit: March 02, 2015, 02:34:11 pm by stahta01 »
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