Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

[Allegro] Visual C++, multiple definition, linker error

Ostatnio zmodyfikowano 2009-07-27 21:06
Autor Wiadomość
steckel
Temat założony przez niniejszego użytkownika
» 2009-07-24 21:26:04
Logi po poprawce zasugerowanej przez Fanael'a:
C/C++
1 >------Build started: Project: dfg, Configuration: Debug Win32------
1 > Compiling...
1 > main.cpp
1 > c:\p rogram files\microsoft visual studio 9.0\vc\include\allegro\gfx.h( 275 )
    : warning C4200
    : nonstandard extension used
    : zero - sized array in struct / union 1 > Cannot generate copy - ctor or copy - assignment operator when UDT contains a zero - sized array 1 > c:\p rogram files\microsoft visual studio 9.0\vc\include\allegro\rle.h( 34 )
    : warning C4200
    : nonstandard extension used
    : zero - sized array in struct / union 1 > Cannot generate copy - ctor or copy - assignment operator when UDT contains a zero - sized array 1 > c:\p rogram files\microsoft visual studio 9.0\vc\include\allegro\font.h( 31 )
    : warning C4200
    : nonstandard extension used
    : zero - sized array in struct / union 1 > Cannot generate copy - ctor or copy - assignment operator when UDT contains a zero - sized array 1 > c:\p rogram files\microsoft visual studio 9.0\vc\include\allegro\fix.h( 45 )
    : warning C4244
    : 'return'
    : conversion from 'double' to 'float'
    , possible loss of data 1 > d:\p rojekty\inne\diablo\main.cpp( 7 )
    : error C4716
    : '_mangled_main'
    : must return a value 1 > Build log was saved at "file://c:\Documents and Settings\User\Moje dokumenty\Visual Studio 2008\Projects\dfg\dfg\Debug\BuildLog.htm" 1 > dfg - 1 error( s )
    , 4 warning( s ) ========== Build
    : 0 succeeded
    , 1 failed
    , 0 up - to - date
    , 0 skipped ==========
P-8757
pompom
» 2009-07-24 22:23:33
A mój post to co?
P-8760
steckel
Temat założony przez niniejszego użytkownika
» 2009-07-25 08:42:38
@pompon, nie wiem jak mogłem pominąć twój post. Dzięki tobie nie będzie już problemów z Allegro, aczkolwiek mam jeszcze problem (chyba) z linkerem:

1>------ Build started: Project: dfg, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>LINK : warning LNK4044: unrecognized option '/-libs'; ignored
1>LINK : warning LNK4044: unrecognized option '/-shared`'; ignored
1>LINK : fatal error LNK1104: cannot open file '`allegro-config.obj'
1>Build log was saved at "file://c:\Documents and Settings\User\Moje dokumenty\Visual Studio 2008\Projects\dfg\dfg\Debug\BuildLog.htm"
1>dfg - 1 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

P-8761
DeBugger
» 2009-07-25 11:48:10
Nie znam się na VC, ale próbuj pobawić się z pragmą:
C/C++
#pragma once(lib, "alleg.lib")
P-8764
steckel
Temat założony przez niniejszego użytkownika
» 2009-07-25 12:49:23
Zastosowałem to tak:
C/C++
#pragma once(lib, "alleg.lib")
#include <allegro.h>
#include "class.cpp"

int main()
{
    return 0;
}
END_OF_MAIN();
Logi:

1>------ Build started: Project: dfg, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>d:\projekty\inne\diablo\main.cpp(1) : error C2143: syntax error : missing ')' before ','
1>d:\projekty\inne\diablo\main.cpp(1) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>d:\projekty\inne\diablo\main.cpp(1) : error C2059: syntax error : 'string'
1>d:\projekty\inne\diablo\main.cpp(1) : error C2059: syntax error : ')'
1>Build log was saved at "file://c:\Documents and Settings\User\Moje dokumenty\Visual Studio 2008\Projects\dfg\dfg\Debug\BuildLog.htm"
1>dfg - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
P-8767
steckel
Temat założony przez niniejszego użytkownika
» 2009-07-25 14:04:26
Ok, logi:

1>------ Build started: Project: dfg, Configuration: Debug Win32 ------
1>Linking...
1>LINK : warning LNK4044: unrecognized option '/-libs'; ignored
1>LINK : warning LNK4044: unrecognized option '/-shared`'; ignored
1>LINK : fatal error LNK1104: cannot open file '`allegro-config.obj'
1>Build log was saved at "file://c:\Documents and Settings\User\Moje dokumenty\Visual Studio 2008\Projects\dfg\dfg\Debug\BuildLog.htm"
1>dfg - 1 error(s), 2 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
P-8769
steckel
Temat założony przez niniejszego użytkownika
» 2009-07-25 21:05:39
Wyczyściłem opcje linkera:

1>------ Build started: Project: dfg, Configuration: Debug Win32 ------
1>Compiling...
1>class.cpp
1>main.cpp
1>Generating Code...
1>Linking...
1>main.obj : error LNK2005: "public: __thiscall cObject::cObject(void)" (??0cObject@@QAE@XZ) already defined in class.obj
1>main.obj : error LNK2005: "public: __thiscall cObject::cObject(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0cObject@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@HH0@Z) already defined in class.obj
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Documents and Settings\User\Moje dokumenty\Visual Studio 2008\Projects\dfg\Debug\dfg.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\User\Moje dokumenty\Visual Studio 2008\Projects\dfg\dfg\Debug\BuildLog.htm"
1>dfg - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
O jaką dokumentację ci chodzi? Allegro czy Visual C++?
P-8775
steckel
Temat założony przez niniejszego użytkownika
» 2009-07-26 12:03:33
Zapisałem wszystko w jednym pliku i też są problemy:
C/C++
#include <string>
#include <allegro.h>
#pragma comment(lib, "alleg.lib")

using namespace std;

class cObject {
public:
    string m_strName;
    int m_iPositionX;
    int m_iPositionY;
    BITMAP * m_bmImage;
    int m_iWidth;
    int m_iHeight;
    cObject();
    cObject( string, int, int, string );
};

class cCharacter
    : public cObject
{
public:
    int m_iHP;
    int m_iAttack;
    int m_iDefense;
    int m_iInjuryMin;
    int m_iInjuryMax;
    int m_iSpeed;
};

class cMonster
    : public cCharacter
{
};

class cPlayer
    : public cCharacter
{
};

cObject::cObject() {
    string m_strName = "Object";
    int m_iPositionX = 0;
    int m_iPositionY = 0;
    BITMAP * m_bmImage = create_bitmap( 50, 50 );
    int m_iWidth = 50;
    int m_iHeight = 50;
}

cObject::cObject( string strName, int iPositionX, int iPositionY, string strPathOfFile ) {
    string m_strName = strName;
    int m_iPositionX = iPositionX;
    int m_iPositionY = iPositionY;
    BITMAP * m_bmImage = load_bmp( const_cast < char *>( strPathOfFile.c_str() ), default_palette );
    int m_iWidth = m_bmImage->w;
    int m_iHeight = m_bmImage->h;
}

int main() {
    return 0;
}
END_OF_MAIN();
Nie ma znaczenia czy jest END_OF_MAIN(), czy go nie ma, bo logi są te same:

1>------ Build started: Project: yui, Configuration: Debug Win32 ------
1>Compiling...
1>main.cpp
1>Linking...
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>C:\Documents and Settings\User\Moje dokumenty\Visual Studio 2008\Projects\yui\Debug\yui.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\User\Moje dokumenty\Visual Studio 2008\Projects\yui\yui\Debug\BuildLog.htm"
1>yui - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
P-8781
1 2 3 « 4 » 5 6 7
Poprzednia strona Strona 4 z 7 Następna strona