• Lucid Dreaming - Dream Views




    Results 1 to 25 of 102
    Like Tree3Likes

    Thread: Ask me about C / C++

    Hybrid View

    1. #1
      Member
      Join Date
      May 2009
      Posts
      139
      Likes
      1
      Yes, I've been figuring that this will suck. But I really need some kind of code for dumping itunes m4a tags to a plain text file Besides the gcc that came with the linux I'm using, I've got borland c++ and symantec c++ for windows.
      I got them back when I was taking some classes in C programming.

      There is a command line in the shell script similar to this for each source file during the compiling stage-

      g++ -g -O2 -Wall -MT obj_files/AP_commons.o -MD -MP -MF
      "./obj_files/AP_commons.Tpo" -c -o obj_files/AP_commons.o
      AP_commons.cpp

      Each of those compile commands gets the following error message, and then doesn't produce any output file-

      g++: cannot specify -o with -c or -S and multiple compilations

      When the link command is run later, there's nothing to link.

    2. #2
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      That's because your syntax isn't quite right. Try this:

      Code:
      obj_files/AP_commons.o: AP_commons.cpp
         g++ AP_commons.cpp -g -O2 -Wall -MT obj_files/AP_commons.o -MD -MP -MF
      "./obj_files/AP_commons.Tpo" -c
      You can't specify where to compile to in the compile line itself, instead you tell it what output file the compile line belongs to.

      The syntax for compiling only goes:
      Code:
      Target: All dependancies (including libraries)
         compiler command

    3. #3
      Member
      Join Date
      May 2009
      Posts
      139
      Likes
      1
      Quote Originally Posted by ninja9578 View Post
      That's because your syntax isn't quite right. Try this:

      Code:
      obj_files/AP_commons.o: AP_commons.cpp
         g++ AP_commons.cpp -g -O2 -Wall -MT obj_files/AP_commons.o -MD -MP -MF
      "./obj_files/AP_commons.Tpo" -c
      You can't specify where to compile to in the compile line itself, instead you tell it what output file the compile line belongs to.

      The syntax for compiling only goes:
      Code:
      Target: All dependancies (including libraries)
         compiler command
      That one didn't work either g++ thought the *.0 and *.Tp0 were the input files and said it couldn't find them.

      I noticed that I couldn't find any place where it actually used the *.Tpo files, so I experimented this morning with a very simple command line of
      g++ AP_commons.cpp -c
      then moving the *.o files to obj_files manually. That cured most of the problems.

      But then I discovered that g++ couldn't find lroundf in the math library, even though it's there just as much as the other math functions the code uses. Fortunately it was simple to replace lroundf with the expression of (int)(n+0.5)

      After that, g++ couldn't find the system getopt.h, even though it's just as much there as any of the other system inlcudes. So I had to specify the absolute file location in the source code.

      But now, the g++ linking stage can't find getopt_long in getopt.h, even though it is there. And I have no idea how to fix that

    4. #4
      Member
      Join Date
      May 2009
      Posts
      139
      Likes
      1
      Ninja,
      since that package refused to compile, and unfortunately your advice didn't work, I spent yesterday afternoon coding a m4a tag dumping program from scratch in VB. It doesn't allow tag editting or anything, but it runs and serves the purpose I needed it for. So that's all taken care of. Maybe I'll even rewrite it in (working) C code when I have more energy, doing that should at least speed it up and allow me to port it into linux too.

    5. #5
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Yep, C code runs circles around VB code.

    6. #6
      Same great taste! Achievements:
      1 year registered 1000 Hall Points Veteran First Class
      Flavour of Night's Avatar
      Join Date
      Jan 2006
      LD Count
      Thousands.
      Gender
      Location
      East Tennessee
      Posts
      308
      Likes
      0
      Quote Originally Posted by ninja9578 View Post
      Yep, C code runs circles around VB code.
      Damned straight. Once compiled, does VB still toss in enormous wodges of non-essential crap from over-stuffed libraries?

    7. #7
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Not really, it's fairly compressed. There is some overhead, for instance, strings have about 4 levels of abstraction around then so every string manipulation requires about 4 times the work as in C++. VB is designed to be a learning tool, not a professional programming app, so the compiler is not very efficient at optimizing.

    8. #8
      Explorer of the Mind SuperSmashcz's Avatar
      Join Date
      Jul 2008
      Gender
      Location
      MD
      Posts
      51
      Likes
      0
      Okay so I've started writing my own 3D engine in C++.. it's got a terrain engine and lighting.. ect. How do I take all my classes and turn it into a library? So like i could be like DDHI_MakeTerrain(..) rather than being like including the classes and calling MakeTerrain(..) Basically.. i could wrap up all my classes and import them all using a single .lib and use it throughout other programs i write using those classes?
      From every time we meet, to every time we part, i will add another memory to my shattered heart, and for every dream we chase, another memory will take its place, so we can remember it one day.

      LD's 15
      DILDs 14
      WILDS 1

    9. #9
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      It depends on your platform and compiler.

      First thing that you need to do is declare all of the methods that you want to use as static stdcall. You can't use classes directly, you need to write an interface. something like this:

      Code:
      //This is the interface header, compiled with both your library and your program
      #include "yourclass.h"
      
      static __stdcall void * New(void){
         return (void*)new yourclass();
      }
      
      static __stdcall SomeMethod(void * handle, int other_params...){
         if (handle){
            yourclass * pthis = (yourclass *)handle;
            pthis -> SomeMethod(other_params...);
         }
      }
      Then you need to set up your IDE to spit out a dll instead of an exe. It depends on your IDE on how to do that, if you're using a makefile, then you have to figure it out yourself, I don't deal with makefiles anymore

      You may or may not need to create and define a DEF file, all that does is tells the compiler what the names of the exported methods are.

      Most compilers will spit out both a dynamic and a static library, dynamic ones are probably better because you can change your engine on the fly. That's how games that use both OpenGL and DirectX do it.
      Last edited by ninja9578; 07-11-2009 at 12:17 AM.

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •