IconHandler.cpp and link errors...

IconHandler.cpp and link errors...

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
sombriks
Posts: 50
Joined: 03 Jan 2008, 15:40

IconHandler.cpp and link errors...

Post by sombriks »

i'm new with this... so take easy guys, ;)

after a good adventure downgrading the machine #1 boost from 1.35 to 1.34.1 the svn version passed the "21% barrier" there;

since it's under hearvy development, i don't know, but my compilation crashade bacause the following issue:

IconHandler.cpp have a call to sqrt; it's passing a value and cmake says that sqrt is ambiguously defined in SMath.h (lines 215,405 and 516) but there are 3 different signatures.

i 've made it in IconHandler.cpp(line 175):

Code: Select all

const float r = streflop::sqrt((streflop::Double)((dx * dx) + (dy * dy))) / 64.0f;
just force the cast and the compilation process finished. but the link step failed, u.u

got that 2 errors:

Code: Select all

[ 73%] Building CXX object CMakeFiles/spring.dir/ExternalAI/GroupHandler.cpp.o
[ 73%] Building CXX object CMakeFiles/spring.dir/ExternalAI/GlobalAICallback.cpp.o
[ 74%] Building CXX object CMakeFiles/spring.dir/ExternalAI/AICheats.cpp.o
Linking CXX executable spring
lib/liblua.a(loslib.cpp.o): In function `os_tmpname(lua_State*)':
loslib.cpp:(.text+0x34): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
CMakeFiles/spring.dir/Lua/LuaUnitRendering.cpp.o: In function `streflop::tan(double)':
LuaUnitRendering.cpp:(.text._ZN8streflop3tanEd[streflop::tan(double)]+0x1c): undefined reference to `streflop_libm::tan(double)'
CMakeFiles/spring.dir/Rendering/IconHandler.cpp.o: In function `streflop::sqrt(double)':
IconHandler.cpp:(.text._ZN8streflop4sqrtEd[streflop::sqrt(double)]+0x1c): undefined reference to `streflop_libm::__ieee754_sqrt(double)'
collect2: ld returned 1 exit status
make[2]: ** [spring] Erro 1
make[1]: ** [CMakeFiles/spring.dir/all] Erro 2
make: ** [all] Erro 2

since i'm newbie on this kind of error, i would like to know from where to start in order to find the cause; usually i have a nice java "StackTrace", i'm not familiar with ".text._ZN8streflop3tanEd[streflop::tan(double)]+0x1c";

i know that i'm near to get my own compiled-from-svn-spring, hope all version that i get can bring me a nice binary, buto not without work, ;)

any idea will be welcome.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: IconHandler.cpp and link errors...

Post by Kloot »

Update to r6050, the call is actually to std::sqrt which lives in cmath.
User avatar
sombriks
Posts: 50
Joined: 03 Jan 2008, 15:40

Re: IconHandler.cpp and link errors...

Post by sombriks »

Nice, i've updated just a few minutes ago and (re)compiled everything again.

i'm still unable to link the final binary, maybe a issue in CMakeLists.txt configuration:

Code: Select all

 99%] Building CXX object CMakeFiles/spring.dir/ExternalAI/GroupAiCallback.cpp.o
[ 99%] Building CXX object CMakeFiles/spring.dir/ExternalAI/GroupHandler.cpp.o
[ 99%] Building CXX object CMakeFiles/spring.dir/ExternalAI/GlobalAICallback.cpp.o
[100%] Building CXX object CMakeFiles/spring.dir/ExternalAI/AICheats.cpp.o
Linking CXX executable spring
lib/liblua.a(loslib.cpp.o): In function `os_tmpname(lua_State*)':
loslib.cpp:(.text+0x34): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
CMakeFiles/spring.dir/Lua/LuaUnitRendering.cpp.o: In function `streflop::tan(double)':
LuaUnitRendering.cpp:(.text._ZN8streflop3tanEd[streflop::tan(double)]+0x1c): undefined reference to `streflop_libm::tan(double)'
collect2: ld returned 1 exit status
make[2]: ** [spring] Erro 1
make[1]: ** [CMakeFiles/spring.dir/all] Erro 2
make: ** [all] Erro 2
i will play with final lines of main CMakeLists.txt, thx for now.
Auswaschbar
Spring Developer
Posts: 1254
Joined: 24 Jun 2007, 08:34

Re: IconHandler.cpp and link errors...

Post by Auswaschbar »

Pleasy try again with new revision. It should work now
User avatar
sombriks
Posts: 50
Joined: 03 Jan 2008, 15:40

Re: IconHandler.cpp and link errors...

Post by sombriks »

good morning Auswaschbar!

you where right, i'm under r6054 and it compiled and linked very well!

i'm also trying to understand that incorrect/missing content erros; maybe i just missed some prefix adjustment, that's why the binary aren't finding the resources.

i will see what changed from 6050 to 6054, i'm on machine #1 now (at work, hehehe) later i wil try svn on machine #2.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: IconHandler.cpp and link errors...

Post by AF »

6054 modified NTai
6053 was a patch kloot applied to the AI interface
6052 was another NTai modification
6051 * change streflop::tan(double) (undefined reference) to std::tan(double) in LuaUnitRendering
6050 * add missing includes
* use ::GetCurrentDirectory() isntead of "./" to get current binary dir
zerver
Spring Developer
Posts: 1358
Joined: 16 Dec 2006, 20:59

Re: IconHandler.cpp and link errors...

Post by zerver »

I just made some MSVS specific fixes related to the above and noticed that it can't find "dirent.h". This file is located in C:\dev-cpp\include.

I don't want to hard-code the above include path in MSVS. I tried using things like %MINGDIR%/include etc. but MSVS does not recognize the environment variables. Any idea how to solve this nicely?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: IconHandler.cpp and link errors...

Post by Tobi »

Do NOT make MSVC build depend on MinGW or MinGW build depend on MSVC, that doesn't make sense.

dirent.h is linux specific include file, need to probably use io.h et al. on windows. (and _findfirst / _findnext instead of opendir / readdir / closedir, there are examples in Spring code)
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

Re: IconHandler.cpp and link errors...

Post by hoijui »

an example:

Code: Select all

#ifdef WIN32
#include <io.h>
#else
#include <dirent.h>
#endif

#ifdef WIN32
#define JARS_REGEX "/*.jar"

int listJars(const char* dir, char** jarNames) {

    int i = 0;
    _finddata_t jarFileInfo;
    char mDir[strlen(dir) + strlen(JARS_REGEX)];
    strcpy(mDir, dir);
    strcat(mDir, JARS_REGEX);

    int handle = _findfirst(mDir, &jarFileInfo);
    if (handle == -1L) {
        return 0;
    }
    jarNames[i] = (char*) malloc(strlen(jarFileInfo.name) * sizeof (char));
    strcpy(jarNames[i], jarFileInfo.name);
    i++;
    while (_findnext(handle, &jarFileInfo) == 0) {
        jarNames[i] = (char*) malloc(strlen(jarFileInfo.name) * sizeof (char));
        strcpy(jarNames[i], jarFileInfo.name);
        i++;
    }
    _findclose(handle);

    return i;
}
#else

static int jarSelector(dirent *fileDesc) {
    return endsWith(fileDesc->d_name, ".jar");
}

int listJarsU(const char* dir, dirent** jars) {
    return scandir(dir, &jars, jarSelector, alphasort);
}

int listJars(const char* dir, char** jarNames) {

    int numJars;
    dirent * jars[MAX_JARS];
    numJars = listJarsU(dir, jars);

    if (numJars > 0) {
        int cnt;
        for (cnt = 0; cnt < numJars; ++cnt) {
            jarNames[cnt] = (char*) malloc(strlen(jars[cnt]->d_name) * sizeof (char));
            strcpy(jarNames[cnt], jars[cnt]->d_name);
        }
    }

    return numJars;
}
#endif
Post Reply

Return to “Engine”