mingw on CodeBlocks

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

mingw on CodeBlocks

max reason

 I have been developing a portable 3D game/graphics/simulation
 engine for over one year now, and recently decided to switch
 IDEs - from eclipse to CodeBlocks plus gcc/g++ on Linux, and
 from VisualStudio2005 to CodeBlocks plus mingw on Windoze.

 The switch on Linux was a success, and I can now compile,
 execute and debug my application on Linux with CodeBlocks.

 The switch on Windoze has been more problematic, and I have
 not been able to resolve the problems and get my program to
 compile successfully, much less execute.  I hope somebody
 can point me to a document that explains everything I must
 do to switch a VisualStudio2005 C/C++ program to CodeBlocks
 with mingw GCC/w32api/bintools/etc, or absent that, help me
 get past the problems I have not been able to resolve.

 A few facts about my program, so nobody misunderstands what
 I am doing (what I need to work).

 #1: For practical purposes, you can imagine that my program
 is a pure 100% native win32 application that only calls the
 following kinds of functions:

   A: win32 API functions
   B: standard C library functions
   C: standard OpenGL functions (including WGL)

 What I want to make totally clear is, my code does not
 expect ANY kind of "compatibility layer" or any other kind
 of "OS-independence" or "XWindows emulation", etc.
 99% of the code is identical on Linux and Windoze, and
 the 1% that is not identical is inside #ifdef LINUX
 and #ifdef WINDOZE blocks.  This includes ALL code that
 opens/creates/manipulates/destroys displays/windows/etc.
 Those routines call xlib/XWindows/GLX functions on Linux,
 or win32/WGL functions on Windoze, and expect absolutely
 no help/layers/anything to make Linux look like Windoze,
 or make Windoze look like Linux.  "cygwin" is unknown to
 my universe of applications, for example.

 #2:  I figured out somehow that I needed to add this line
 to the #define tab in the CodeBlocks IDE:

   __MSVCRT_VERSION__=0x0700

 #3:  My application contains two assembly language files:

   A:  icemathasm.asm ::: icemathasm.s
   B:  igasm.asm ::: igasm.s

 As you might expect, the .asm files are in MASM syntax,
 and the .s files are in standard Linux/ATT/GNU syntax.
 On Linux I added the two .s files to my project, and
 they (and the whole project) compiles/assembles/builds
 successfully and executes correctly.

 In VisualStudio2005 of course, I added the .asm files
 to my project, and that builds and executes correctly.

 In CodeBlocks + mingw on Windoze, I am guessing I am
 supposed to add the .s files to my project, since this
 is what the GNU tools presumably expect (and I do see
 the "as.exe" file in the mingw "bin" folder, which
 reinforces that assumption on my part).  However, this
 seems not to be working, as is explained below.

 -----

 Here are a couple of the errors I encounter trying to
 compile this application.  Perhaps someone will notice
 what stupid erroneous assumption I am making, and give
 me the simple answers, or point me to a link that
 explains "CodeBlocks plus mingw for massive dummies",
 which is what I feel like at the moment.

 #1: 'memset' is not declared in this scope.
 #2: many "undefined references" to functions in .s file:
     A: undefined reference to '_math_sin'
     B: undefined reference to '_math_cos'
     C: undefined reference to '_math_abs'
     D: undefined reference to '_math_sqrt'
     #: and dozens more similar errors

 #1: the documentation for the memset() function says
 #include <string.h> is necessary to declare memset().
 Sure enough, when I look inside the <string.h> file
 in the "c:/mingw/include/" directory I see that the
 memset() function *is* declared.  Thus, I am confused.

 #2: all functions mentioned in the "undefined reference"
 errors are inside my icemathasm.s assembly-language file.
 That file is added to my CodeBlock project, and is shown
 inside the "ASM sources" section of the project workspace
 in the IDE.  Furthermore, I do see that the build process
 has created a icemathasm.o file - which presumably would
 contain those functions.  Thus, again I am confused.

 -----

 I'm not sure how many more errors will appear once
 these are corrected, but apparently it stops the
 compile process at the first encountered error, since
 I had to comment out the call of "memset()" before it
 generated the "undefined reference" errors.  I do not
 have "stop compiling after first error" checked, but
 it seems to be stopping at the end of the first file
 that contains errors even so.

 As will many "beginners" on a new environment, I am
 probably asking totally stupid questions that show
 how naive I am to obvious facts.  Sorry for that.
 I will appreciate your tolerance, and any help.
 Thanks.  Max


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) HTML/MIME encoded mail
3) Improper quoting
4) Improper trimming
Reply | Threaded
Open this post in threaded view
|

Re: mingw on CodeBlocks

Tony Richardson
max reason <maxreason@...> writes:
>  I have been developing a portable 3D game/graphics/simulation
>  engine for over one year now, and recently decided to switch
>  IDEs - from eclipse to CodeBlocks plus gcc/g++ on Linux, and
>  from VisualStudio2005 to CodeBlocks plus mingw on Windoze.

Part of problem description pruned from original posting.

>
>  #1: 'memset' is not declared in this scope.
>  #2: many "undefined references" to functions in .s file:
>      A: undefined reference to '_math_sin'
>      B: undefined reference to '_math_cos'
>      C: undefined reference to '_math_abs'
>      D: undefined reference to '_math_sqrt'
>      #: and dozens more similar errors
>
>  #1: the documentation for the memset() function says
>  #include <string.h> is necessary to declare memset().
>  Sure enough, when I look inside the <string.h> file
>  in the "c:/mingw/include/" directory I see that the
>  memset() function *is* declared.  Thus, I am confused.
>
>  #2: all functions mentioned in the "undefined reference"
>  errors are inside my icemathasm.s assembly-language file.
>  That file is added to my CodeBlock project, and is shown
>  inside the "ASM sources" section of the project workspace
>  in the IDE.  Furthermore, I do see that the build process
>  has created a icemathasm.o file - which presumably would
>  contain those functions.  Thus, again I am confused.

More pruning.

>  Thanks.  Max

Not sure if this is your problem or not, but g++ automatically
prepends an underscore "_" to C/C++ function names under
Windows.  This is to be compatible with other Windows compilers.  
Nothing is prepended under Linux.  This prepending does not
happen automatically for routines defined in assembly.
This means that your assembly routines have to be named
"_math_sin" in your Windows assembly source but just "math_sin"
under Linux.

You can write "portable" assembly for Windows/Linux under gas,
but you may need to run your assembly source through the
preprocessor.  (See the __USER_LABEL_PREFIX__ entry under the
Common Predefined Macros section of the cpp info documentation.)
I can provide more detail if this turns out to be the problem
and you are looking for Windows/Linux portability.

Tony Richardson



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) HTML/MIME encoded mail
3) Improper quoting
4) Improper trimming
Reply | Threaded
Open this post in threaded view
|

Re: mingw on CodeBlocks

Tony Richardson
Tony Richardson <richardson@...> writes:

> max reason <maxreason@...> writes:

Part of problem description pruned from original posting.

> >  #2: many "undefined references" to functions in .s file:
> >      A: undefined reference to '_math_sin'

More pruning.

> >  Thanks.  Max

It looks as if "_aligned_malloc" problem (reported in a different
thread) might also be due to a missing underscore?  Did you notice
the undefined reference to "__aligned_malloc" has two leading
underscores?  You will need both underscores in the assembly
source definition.

Tony Richardson



------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users

_______________________________________________
This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.

Most annoying abuses are:
1) Top posting
2) HTML/MIME encoded mail
3) Improper quoting
4) Improper trimming