Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
I'm an administrator not a developer so bear with me. Apologize but my post is in the attached file. No matter what I tried could not submit my post, kept ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    9

    C++ runtime symbol error

    I'm an administrator not a developer so bear with me.

    Apologize but my post is in the attached file. No matter what I tried could not submit my post, kept getting "you must submit 15 posts before you can include external URL's" or something similiar.

    Been working this issue for a week and would seriously appreciate an assist.

    Kirk
    Attached Files Attached Files

  2. #2
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    Yeah, that 'no posting URLs' thing is damn annoying.

    Anyway, a run-time "symbol not found" error occurs when the dynamic linker can find the library it wants the symbol from, but that library doesn't contain the symbol any more - i.e. it's been removed or changed since it was compiled.

    From nm and grep on my libstd++.so, it looks like "std::codecvt<char, char, mbstate_t>::id" has been changed to "std::codecvt<char, char, __mbstate_t>::id" (i.e. underscores added to mbstate_t). In this case, the old code will be looking in the right library, but for the wrong symbol.

    My best bet for fixing this problem would be to recompile against the newer libstdc++. I don't know how hard that'll be with a newer version of gcc, but it should be relatively painless if the software was written well.


    P.S. Feel free to ask about any problems you have compiling (or if you don't know where to start). Some problems may be obvious to programmers, but not so obvious to non-programmers, especially if you've never had to rebuild anything before...

  3. #3
    Just Joined!
    Join Date
    Jul 2010
    Posts
    9
    J.G. thanks for the response. Funny you mention recompile since I had given that a shot but it failed (didnt include that in the post).
    Again the target application is generically referred to herein as "app"

    Machine B
    virutal linux machine (Fedora 13, with every gcc library I could find installed. Make file supplied by the developer)

    Compile output; I listed the apparent offending line from both source/header files.
    Code:
    [root@localhost up2]# make
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c app.cpp -o app.o
    In file included from app.cpp:7:
    FGFDMExec.h: In member function ‘bool FGFDMExec::SetModelPath(std::string)’:
    FGFDMExec.h:156: error: ‘index’ was not declared in this scope
    make: *** [app.o] Error 1
    FGFDMExec.cpp
    Code:
     
    155 Output = new FGOutput(this);
    156
    157 State = new FGState(this); // This must be done here, as the FGState
    158                                    // class needs valid pointers to the above
    159                                    // model classes
    160
    FGFDMExec.h
    Code:
    153 /* Store full path to rocket model.
    154     Needed as engines will be looked for in this directory */
    155 bool SetModelPath(string path) {
    156    if ( index(path.c_str(),'/') )
    157		modelPath = path.substr(0,1+path.rfind("/"));
    158	return true;
    159 }

  4. #4
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    The "index()" function is defined in strings.h.

    Solution: Add "#include <strings.h>" (on its own line) to the top of FGFDMExec.h. Recompile until you hit the next problem...

  5. #5
    Just Joined!
    Join Date
    Jul 2010
    Posts
    9
    Oh yeaaaa! That's what I like to see. FGFDMExec.h compiled but make bailed on FGMaths.cpp. These appear to be more involved. I do know malloc = memory allocation....scary stuff.

    Code:
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGMaths.cpp -o FGMaths.o
    FGMaths.cpp:8:22: error: iostream.h: No such file or directory
    FGMaths.cpp: In function ‘void solve(double*, long int, double*)’:
    FGMaths.cpp:25: error: ‘malloc’ was not declared in this scope
    FGMaths.cpp:30: error: ‘free’ was not declared in this scope
    FGMaths.cpp: In function ‘void ludcmp(double*, long int, long int*, double*)’:
    FGMaths.cpp:43: error: ‘malloc’ was not declared in this scope
    FGMaths.cpp:50: error: ‘cerr’ was not declared in this scope
    FGMaths.cpp:50: error: ‘endl’ was not declared in this scope
    FGMaths.cpp:87: error: ‘free’ was not declared in this scope
    make: *** [FGMaths.o] Error 1
    and only these to go:
    Code:
    FGMaths.o \
    FGMatrix33.o \
    FGModel.o \
    FGNozzle.o \
    FGOutput.o \
    FGPosition.o \
    FGPropulsion.o \
    FGRotation.o \
    FGState.o \
    FGTank.o \
    FGThruster.o \
    FGTranslation.o \
    datcom.o \
    utc2lst.o \
    hwm93.o
    I'm picking up on the pattern. Include means hey there is lib my code refers to and I gotta refer to it. Hopefully that is what most of the errors will be. I'm not a C developer and only dabbled in Java and Basic.

  6. #6
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    Quote Originally Posted by kdwoell View Post
    Code:
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGMaths.cpp -o FGMaths.o
    FGMaths.cpp:8:22: error: iostream.h: No such file or directory
    FGMaths.cpp: In function ‘void solve(double*, long int, double*)’:
    FGMaths.cpp:25: error: ‘malloc’ was not declared in this scope
    FGMaths.cpp:30: error: ‘free’ was not declared in this scope
    FGMaths.cpp: In function ‘void ludcmp(double*, long int, long int*, double*)’:
    FGMaths.cpp:43: error: ‘malloc’ was not declared in this scope
    FGMaths.cpp:50: error: ‘cerr’ was not declared in this scope
    FGMaths.cpp:50: error: ‘endl’ was not declared in this scope
    FGMaths.cpp:87: error: ‘free’ was not declared in this scope
    make: *** [FGMaths.o] Error 1
    I'm picking up on the pattern. Include means hey there is lib my code refers to and I gotta refer to it. Hopefully that is what most of the errors will be.
    Yeah, there are a lot of common errors that you only need a basic knowledge of how #include directives work (and sometimes knowing about makefiles helps) that can get you quite far.

    Anyway, in case you've not figured out the above:

    • "iostream.h" is the old-style of includes with a .h after it - so in FGMaths.cpp you need to replace "#include <iostream.h>" with "#include <iostream>". That should also solve the problems with cerr and endl
    • malloc() and free() can be obtained by "#include <stdlib.h>".

  7. #7
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    Quote Originally Posted by JohnGraham View Post
    Yeah, there are a lot of common errors that you only need a basic knowledge of how #include directives work (and sometimes knowing about makefiles helps) that can get you quite far.

    Anyway, in case you've not figured out the above:

    • "iostream.h" is the old-style of includes with a .h after it - so in FGMaths.cpp you need to replace "#include <iostream.h>" with "#include <iostream>". That should also solve the problems with cerr and endl
    • malloc() and free() can be obtained by "#include <stdlib.h>".
    Also, it is not recommended to use malloc() and free() (including calloc(), realloc(), et al) in C++ programs. Use new and delete instead. In 10M (million) lines of C++ code that I was responsible for in the development of a major software system for semiconductor manufacturing, we had less than a half-dozen uses of malloc/free and such - only for some real low-level C-style programming and C-compatible function calls.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  8. #8
    Just Joined!
    Join Date
    Jul 2010
    Posts
    9
    Your right. Had more recompiles with errors that were solved by various include statements. Now, here is where the monkey is fired, and real thought must start.

    Code:
    [root@localhost somedir]# make
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c app.cpp -o app.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGAerodynamics.cpp -o FGAerodynamics.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGAircraft.cpp -o FGAircraft.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGAtmosphere.cpp -o FGAtmosphere.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGAuxiliary.cpp -o FGAuxiliary.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGColumnVector3.cpp -o FGColumnVector3.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGColumnVector4.cpp -o FGColumnVector4.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGConfigFile.cpp -o FGConfigFile.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGEngine.cpp -o FGEngine.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGFCS.cpp -o FGFCS.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGFDMExec.cpp -o FGFDMExec.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGForce.cpp -o FGForce.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGInertial.cpp -o FGInertial.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGInitialCondition.cpp -o FGInitialCondition.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGJSBBase.cpp -o FGJSBBase.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGMassBalance.cpp -o FGMassBalance.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGMaths.cpp -o FGMaths.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGMatrix33.cpp -o FGMatrix33.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGModel.cpp -o FGModel.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGNozzle.cpp -o FGNozzle.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGOutput.cpp -o FGOutput.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGPosition.cpp -o FGPosition.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGPropulsion.cpp -o FGPropulsion.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGRotation.cpp -o FGRotation.o
    g++ -DHAVE_CONFIG_H -Wall -g -I. -c FGState.cpp -o FGState.o
    FGState.cpp: In member function ‘FGColumnVector3& FGState::CalcEuler()’:
    FGState.cpp:602: error: ‘FLT_EPSILON’ was not declared in this scope
    make: *** [FGState.o] Error 1
    [root@localhost somedir]#
    I guess FLT_EPSILON is a function call or something that State cant find?

    Code:
    FGColumnVector3& FGState::CalcEuler(void) {
      // 
      double cy;
        cy = sqrt(mTl2b(1,1)*mTl2b(1,1) + mTl2b(2,1)*mTl2b(2,1));
    
        if ( fabs(cy) > 16*FLT_EPSILON ) {
            vEuler(ePhi) = atan2(mTl2b(3,2), mTl2b(3,3));
            vEuler(eTht) = -atan2(-mTl2b(3,1), cy);
    		vEuler(ePsi) = atan2(mTl2b(2,1), mTl2b(1,1));
    	}
        else {
            vEuler(ePhi) = atan2(-mTl2b(2,3), mTl2b(2,2));
            vEuler(eTht) = -atan2(-mTl2b(3,1), cy);
            vEuler(ePsi) = 0.0;
        }
    
      return vEuler;
    }

  9. #9
    Linux Newbie
    Join Date
    Mar 2010
    Posts
    121
    Quote Originally Posted by kdwoell View Post
    Code:
    FGState.cpp: In member function ‘FGColumnVector3& FGState::CalcEuler()’:
    FGState.cpp:602: error: ‘FLT_EPSILON’ was not declared in this scope
    make: *** [FGState.o] Error 1
    [root@localhost somedir]#
    I guess FLT_EPSILON is a function call or something that State cant find?
    As it happens, this is yet another #include - this time for float.h (FLT_EPSILON is the smallest increment above (or below? can't remember) 1 the machine can represent with the "float" floating-point type).

  10. #10
    Just Joined!
    Join Date
    Jul 2010
    Posts
    9
    Well I got the code to compile, and it runs! I had to put in the last include you mentioned and then I had to install g2c for Fortran 77 since our application relies on some legacy Fortran code (can u believe it circa 2010)?

    I kept getting this error even after installing g2c Fortran:

    Code:
    /usr/bin/ld: cannot find -lg2c
    I can locate libg2c at
    /usr/lib/libg2c.so.0
    I checked and I have a symbolic link for g2c:

    Code:
    [root@localhost somedir]# locate libg2c.so.0
    /usr/lib/libg2c.so.0
    /usr/lib/libg2c.so.0.0.0
    [root@localhost somedir]# ls -la | more
    lrwxrwxrwx.   1 root root       15 Jul 18 20:42 libg2c.so.0 -> libg2c.so.0.0.0
    So i hardcoded the path in the make file to where g2c lives. Not eloquent but it worked.
    Code:
    app:	app.o $(OBJS) $(FILTEROBJS)
    	#$(CC) $(CFLAGS) app.o $(OBJS) $(FILTEROBJS) -o app -lg2c -lc -lm 
    	$(CC) $(CFLAGS) app.o $(OBJS) $(FILTEROBJS) -o app /usr/lib/libg2c.so.0.0.0 -lc -lm
    I can't express my gratitude enough. So tell me O' developer what is the proper way to specify the path in the Makefile?

Page 1 of 2 1 2 LastLast

Posting Permissions

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