User forums > Using Code::Blocks

Creating a 32-bit DLL

(1/1)

alfredfvj:
Hello,

We are currently converting a "legacy" system written in VFP to C++. The system is very large i.e., it covers almost all corporate applications. As such, we want to implement the migration to C++ on a piecemeal approach starting with the general functions using DLL.

Using CodeBlocks wizard, I created a minimal DLL project and compiled it without encountering any errors. However, when I tried to use it in VFP under Windows 11, I got an error "Cannot load 32-bit DLL".

I assumed that the DLL generated was 64-bit so I went back to CB, edited the compiler settings and checked Target x86 (32bit) [-m32] and rebuilt the project. This time, I encountered 21 errors all of which were related to ld.exe not able to find library files. So, I edited the linker settings to include the lib files (ex. libuser32.a, libmingw32.a, libmoldname.a, etc.) including the full path. I also included in the Seach Directories the folder where these files are located. When I built the project, I still got the same "cannot find..." errors. 

I tried searching Google for answers but found no solution that worked. Any help will be greatly appreciated.

Thanks.

stahta01:
To build an 32 bit DLL you need to use an 32 bit compiler toolchain.
Using an 64 bit compiler toolchain in theory would work; but, the of people who tried that and succeeded is zero in the post I have read on this website.

Note: The above is for MinGW GCC Windows based toolchains; I hear on Linux the problem might not exist.

Tim S.

Miguel Gimenez:
The -m32 and -m64 flags are effective only if you have a multilib toolchain, something infrequent. You should install a toolchain targetting the desired bitness and do not use -m at all. You can have two toolchains, one for 32-bit targets and another for the 64-bit ones.

nenin:

--- Quote from: alfredfvj on July 27, 2023, 07:27:20 am ---Hello,

We are currently converting a "legacy" system written in VFP to C++.****
I tried searching Google for answers but found no solution that worked. Any help will be greatly appreciated.

Thanks.

--- End quote ---
I do it like this. I have 3 actual used mingw, 32b, 32b/XP (this is different story) and 64b.
I have two separated folders for 32 nd 64 bit versions.
In each folder I have separated subfolders for  each versions.
So, it looks like this:
c:\mingw32\winlibs09.3_XP\
c:\mingw32\winlibs12.1\
In dedicated compiler folder I have subfolder for third-party libraries, which I built by myself.
I switch path to required compiler when I need exact version.
Also in C::B I prepared separated profile for each compiler, so it looks like that (example for XP, "comp.png"). And assign this profile to project ("prof.png").
Compilers might be from WinLibs or Nixman. You can use gdb64 for both 32 and 64 versions, if GDB fresh enough (v11, i guess).

Navigation

[0] Message Index

Go to full version