CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    Re: src file won't compile anymore

    Quote Originally Posted by LMHmedchem View Post
    I have attached a .zip with the src file and header.
    It doesn't compile:
    Code:
    $ gcc igroup_maps.cpp
    In file included from igroup_maps.cpp:4:
    igroup_maps.h:27: error: expected init-declarator before "extern"
    igroup_maps.h:27: error: expected `,' or `;' before "extern"
    Invest an extra 2 seconds of effort & actually compile the code before asking other people to troubleshoot the slow compile problem.

  2. #17
    Join Date
    May 2009
    Location
    Boston
    Posts
    375

    Re: src file won't compile anymore

    Quote Originally Posted by Martin O View Post
    It doesn't compile:
    Code:
    $ gcc igroup_maps.cpp
    In file included from igroup_maps.cpp:4:
    igroup_maps.h:27: error: expected init-declarator before "extern"
    igroup_maps.h:27: error: expected `,' or `;' before "extern"
    Invest an extra 2 seconds of effort & actually compile the code before asking other people to troubleshoot the slow compile problem.
    This does compile, I can post the compiled object if you want it. After looking at the file I posted in the .zip, there is a missing semicolon at the end of line 25. I must have missed that on my last edit. Other than that, it should be fine.

    LMHmedchem

  3. #18
    Join Date
    Apr 1999
    Posts
    27,449

    Re: src file won't compile anymore

    Quote Originally Posted by LMHmedchem View Post
    I will try the small program, but I think the issue is linking to the std lib in my make.
    Compiling is not linking.

    To see if it is a slow compile, then you could use the -c switch to just compile the source code instead of compiling and linking. The linker used is ld (as far as I remember), not gcc (which is just a compiler, not a linker).

    Regards,

    Paul McKenzie

  4. #19
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    Re: src file won't compile anymore

    Quote Originally Posted by LMHmedchem View Post
    This does compile
    ....
    After looking at the file I posted in the .zip, there is a missing semicolon at the end of line 25.
    Which....makes it not compile.

    At any rate, no problems compiling here:
    Code:
    $ g++ -dumpversion
    3.4.4
    
    $ date
    Thu May 26 15:18:41 CDT 2011
    
    $ g++ -c igroup_maps.cpp
    
    $ date
    Thu May 26 15:18:46 CDT 2011
    See how I copy/pasted the actual commands I ran in my command prompt? You should do that, otherwise everyone has to keep guessing.

  5. #20
    Join Date
    May 2009
    Location
    Boston
    Posts
    375

    Re: src file won't compile anymore

    Quote Originally Posted by Martin O View Post
    Which....makes it not compile.

    At any rate, no problems compiling here:
    For some reason, I wasn't expecting folks to try to compile this. I just though someone might take a look at it and see if there was something obvious that was visable.

    Well this is odd, if I compile from the shell with no flags,
    Code:
    $ time g++ -c igroup_maps.cpp
    
    real    0m2.078s
    user    0m0.700s
    sys     0m0.326s
    it compiles quickly. When I compile just that object from my make file,
    Code:
    $ time make ver=igrp -f MAKE_11-04-29.mingw client
    g++ -mno-cygwin -O2 -DWINVER -DDATESTR=\"0.11.05.26\" -DRELEASEVERSION -DLICNUM=0 -DV
    ERNUM=5 -c -o bld_CYGWIN_NT-5.1_g34_1.7.i686/igroup_maps.o src/igroup_maps.cpp
    
    real    3m15.968s
    user    3m14.471s
    sys     0m0.926s
    it takes 3+ min. A few seconds of this is the linker, but I can see when the linker starts and prints its output and it is only a few seconds. The make file is passing allot more flags and such, so I decided to add some of them to the shell command. It appears that the issue is using the -O2 optimize level. If I complie with -O2,
    Code:
    $ time g++ -O2 -c igroup_maps.cpp
    
    real    3m14.656s
    user    3m13.872s
    sys     0m0.451s
    If I use -O0 in the make or shell, then I am back to 2 seconds to compile.

    I know that using various levels of optimize can increase the compile time, but I didn't think it would increase by a factor of 100. This underscores the comment by Martin about posting the exact compile command, so thanks for that pointer.

    I am still a bit mystified as to why I didn't notice this when I was writing the code, since I have used the same make for quite a while. That had me convinced that the slowdown was the result of a recent change in the code, and I am not yet un-convinced. I would like to know what people think about this being simple an issue of using optimize, or if I should be looking for some other underlying issue.

    LMHmedchem

  6. #21
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    Re: src file won't compile anymore

    I got the same slowness when I added the -O2 option. It's the iniIgrpDesMap function that is causing the slow compile time. I think you can improve compile time by adding to your map like this:
    Code:
    	igrpDesMap["AM_16"] = desVal(-1,-1, "NNNN");
    instead of this:
    Code:
    	igrpDesMap.insert(pair<string,desVal>("AM_16",  desVal(-1,-1, "NNNN") ));
    I tested a cut down version of the program & it improved compile time-- adding the first 17 entries went from roughly .8ms to .5ms.

  7. #22
    Join Date
    May 2009
    Location
    Boston
    Posts
    375

    Re: src file won't compile anymore

    Thanks, I'll try that. Do you think that the issue is the use of insert() or the use of pair?

    LMHmedchem

    I'm getting the following compile error,
    Code:
    $ time make ver=igrp -f MAKE_11-04-29.mingw client
    g++ -mno-cygwin -O2 -DWINVER -DDATESTR=\"0.11.05.27\" -DRELEASEVERSION -DLICNUM=0 -DV
    ERNUM=5 -c -o bld_CYGWIN_NT-5.1_g34_1.7.i686/igroup_maps.o src/igroup_maps.cpp
    
    /usr/lib/gcc/i686-pc-mingw32/3.4.4/include/c++/bits/stl_map.h: In member function `_T
    p& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const _Key&) [with _Key = std::s
    tring, _Tp = desVal, _Compare = std::less<std::string>, _Alloc = std::allocator<std::
    pair<const std::string, desVal> >]':
    src/igroup_maps.cpp:189:   instantiated from here
    /usr/lib/gcc/i686-pc-mingw32/3.4.4/include/c++/bits/stl_map.h:339: error: no matching
     function for call to `desVal::desVal()'
    src/igroup_maps.cpp:189: note: candidates are: desVal::desVal(const desVal&)
    src/igroup_maps.h:13: note:                 desVal::desVal(int, int, const std::string&)
    make: *** [bld_CYGWIN_NT-5.1_g34_1.7.i686/igroup_maps.o] Error 1
    It doesn't seem to like the call to create the object.
    Last edited by LMHmedchem; May 26th, 2011 at 11:22 PM.

  8. #23
    Join Date
    May 2002
    Location
    Lindenhurst, NY
    Posts
    867

    Re: src file won't compile anymore

    Oh yeah, I forgot to mention I also had to add a no-args constructor to desVal:
    Code:
    class desVal
    {
    ..    
        desVal() :
            desPos(0),
            HdesPos(0)
        {
        }
    ...
    };
    I thought it might be slower because of using 'pair'. I know that templates are expanded at compile time...maybe template expansion plus optimization caused the compiler to work a lot harder. Just a guess.

  9. #24
    Join Date
    May 2009
    Location
    Boston
    Posts
    375

    Re: src file won't compile anymore

    Quote Originally Posted by Martin O View Post
    Oh yeah, I forgot to mention I also had to add a no-args constructor to desVal:
    Code:
    class desVal
    {
    ..    
        desVal() :
            desPos(0),
            HdesPos(0)
        {
        }
    ...
    };
    I thought it might be slower because of using 'pair'. I know that templates are expanded at compile time...maybe template expansion plus optimization caused the compiler to work a lot harder. Just a guess.
    Where do I add this? Does it take the place of the current constructor?

    This works and compiles in just a few seconds.
    Code:
    class desVal {
       public :
    
       desVal() : desPos(0), HdesPos(0) { }
    
       desVal(const int desPos_P, const int HdesPos_P, const std::string& igrp_mark_P) :
          desPos(desPos_P),
          HdesPos(HdesPos_P),
          igrp_mark(igrp_mark_P) 
          { }
    
       int desPos, HdesPos;
       std::string igrp_mark;
    };
    What is the need for the second constructor? It is curious that it should need more than one, and it seems to need to use both if it is going to load the proper values to the object data members.

    ...anyway, the format for the map is more compact this way anyway, and it will probably work a bit faster without the need to invoke pair and insert. It is still strange that I never noticed the long compile times while I was working on it.

    LMHmedchem

Page 2 of 2 FirstFirst 12

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured