Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

Problem migrating Linux CodeBlocks project to Windows; Linking libraries

Sabotender

New Coder
I am completely unaccustomed to using windows as the operating system environment because I have barely… Unique… Preferences when it comes to writing code.

Here is how I set up my coding environment under Debian Linux:

Sudo apt-get install...


build-essential
codeblocks
SDL2
SDL2-image
SDL2-mixer
ncurses
libchipmunk0d3

And here is how I set up the Compiler build environment for Codeblocks running on Debian Linux:


Compiler Settings


COMPILER FLAGS
Enable Extra Compiler Warnings: ticked
Stop Compiling after first Error: ticked



LINKER SETTINGS

Link libraries
ncurses
menu
panel
chipmunk
SDL2
SDL2_mixer
SDL2 ttf
SDL2 image


SEARCH DIRECTORIES

compiler

/usr/include/SDL2
/usr/include/GLES2
/usr/include/EGL
/usr/include/GL/usr/include/chipmunk

Linker

/usr/lib/i386-linux-gnu




Under windows, here's the steps I have taken to set up the under the same/similar development environment, as best as I could:


I downloaded the MingW64 compiler from here:


Specifically from the quote, taken from their site, 'GCC 13.1.0 (with POSIX threads) + LLVM/Clang/LLD/LLDB 16.0.5 + MinGW-w64 11.0.0 (UCRT) - release 5 (LATEST)'

I downloaded the SDL2 Library here:


SDL2-Image Library here:


SDL2-mixer here:


Chipmunk Physics library version 6.1x here:


for all of those libraries, I downloaded specifically the 'win32-x86' variety. I am not certain those were the correct ones, I assumed it was because of the version of Mingww that I downloaded, to match.

And here is how I set up the Compiler build environment for Codeblocks running on Microsoft Windows:

COMPILER FLAGS
Enable Extra Compiler Warnings: ticked
Stop Compiling after first Error: ticked



LINKER SETTINGS

Link libraries

SDL2
SDL2_mixer
SDL2_image
C:\Users\Sabotender\Documents\C Source\chipmunk\bin\Release\libchipmunk.a


SEARCH DIRECTORIES

compiler
C:\mingw64\include\SDL2

C:\Users\Sabotender\Documents\C Source\chipmunk\include\chipmunk

Linker

C:\mingw64\bin


I created a new Console project under Codeblocks because I couldn't build for the first time without one, where I could easily under the Linux version 😕

I received no build warnings or errors for the SDL2 library, which I installed via Google research, which included dropping the dlls in the Mingww64 bin directory, and the header files in the appropriate directory, but the primary source of my woes is practically the heart of my project that I've been unable to access, is that Chipmunk library!

You may noticed tat I linked that chipmunk library which ends in an a, but I have no idea whether or not it is correct. I really REALLY hate building other people's code. I only really use precompiled binaries set for the Operating system that I am currently using at that time. based on some research I performed via Google, I created a new CodeBlocks static library project,opened the chipmunk.c code, linked the headers, changed the build target to 'Release', and it built successfully, or so I thought, because when I then tried plugging in this information in my own project, immediately I received 53 Build errors, for which are a few examples I have pasted below:

C:\mingw64\include\chipmunk\cpShape.h|169|undefined reference to `cpBodyActivate'|

another:

C:\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\13.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Sabotender\Documents\C Source\Yet Another 2D Game\main.c|2166|undefined reference to `cpSpaceRemoveShape'|


And another, for posterity:
C:\mingw64\bin\..\lib\gcc\x86_64-w64-mingw32\13.1.0\..\..\..\..\x86_64-w64-mingw32\bin\ld.exe: C:\Users\Sabotender\Documents\C SourceYet Another 2D Game\main.c|10750|undefined reference to `cpBodyApplyImpulse'|

I have spent several days trying to resolve this issue. I am not entirely certain where I am making the mistake. It might be because I built the library incorrectly,, but it's probably because I am not linking the library correctly. It could be something else, sorry for cherry-picking.

...


I was able to work on my project without problems, for a very very long time, but due to unforeseen circumstances, I am no longer able to use Linux for writing code. I remember several years ago trying to set up this project initially under Windows, and it was every bit as difficult getting things set up, because, unlike working with Linux, one cannot simply 'apt-get install' and everything that you need is automagically installed in the directories that it they are supposed to, and not needing to fiddle with things like environment variables and whatnot.

I chose using CodeBlocks for writing code and working on my project, because I prefer to keep things simple and not working with silly things like make files, or anything at the command line, because I very much prefer to keep out of the CLI as much as I can.

I actually sought help on numerous Discord servers, and even on IRC (thanks a lot, libera), and the first comment I received was, 'WHY are you using something like CodeBlocks,WHY aren't you useing Microsoft Visual Studio?!?!?!?!'

I don't think I should find the need to explain myself each and every time I decide to use something that is not popular. It is very exhausting.

I know that I am ranting, I'm just tired and frustrated. 😵

With all that have been said, I discovered this Forum, and I noticed, to my extreme delight and surprise, that there were previous threads that matched 'CodeBlocks'! I registered immediately, and I have high hope to possibly find someone with experience using CodeBlocks and/or can see where I am making this horrible mistake with the Chipmunk library,and can reach a positive solution.



Thank you so very much for reading my thread, and I hope I provided thorough documentation regarding My goals.
 
I've compiled multiple versions of the chipmunk library in attemptto get to compile with my code. Static libs, dynamic linkedlibraries, etc. What I do not understand is how my code compilesperfectly, without error within a Linux environment, but it seemsimpossible within Windows. I shouldn't need to modify my code inorder for it to be acceptable. It might be because the C compilerwithin build-essential is different from what is within mingw64.


I had hoped that there may have been a response or two in order to help tackle this frusturating curiosity, but perhaps I did not provideenough information in regards to my problem. I did my best to give all the things that I did for the code migration. I seriously believethat the chipmunk 2D library is completely different and eventhe headers are different as well.


The last error I received when I tried to build my source was,"error: invalid use of incomplete typedef 'cpShape'|" butthat was one of many errors like that.


and this is why I was thinking, that if my code compilesjust fine within Linux, but I receive something like that inWindows, is it because I am trying to use completely differentversions of the Chipmunk 2D library?



I might be asking questions in an inappropriate forum. Would it bebetter if I asked this that specialises in a Code:Blocks setting? Perhaps a Moderator could provide some direction.
 
When moving from Linux to Windows, there are a few differences in the process. Instead of using apt-get, which is specific to Linux, you'll need to manually download the required libraries for Windows. To get started, search for the Windows versions of the libraries you mentioned - SDL2, SDL2-image, SDL2-mixer, ncurses, and libchipmunk0d3. Look for their official websites or reliable sources to download them. Once you have the libraries, you'll need to set up the compiler build environment in CodeBlocks on Windows.
 
In the Compiler Settings, you might need to make some adjustments to the flags to match the Windows environment. Unfortunately, I don't have the exact settings for you, but you can try enabling options like "Extra Compiler Warnings" and "Stop Compiling after first Error" to improve your project's compatibility.
 
Last edited by a moderator:

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom