An error in C++

1. I am using VS 8
2. The program I use is
#include <LEDA/system/basic.h>
#include <LEDA/numbers/integer.h>
#include <iostream>
using namespace std;
using namespace leda;

main() {cout << "factorial of 6 is: " << factorial( 6 ) << endl; return 0;}

3.When I try and build I get
1>------ Build started: Project: ThirdLedaFactorial, Configuration: Debug Win32 ------
1>Compiling...
1>Third.cpp
1>f:\mywork\visual studio 2008\projects\thirdledafactorial\thirdledafactorial\third.cpp(7) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>Build log was saved at "file://f:\MyWork\Visual Studio 2008\Projects\ThirdLedaFactorial\ThirdLedaFactorial\Debug\BuildLog.htm"
1>ThirdLedaFactorial - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

4. When I change the return type of main to int or integer I get a mistake
5.What am I doing wrong?

So
1
2
3
int main() {
     return 0;
}

doesn't work?? :-P
No.

int main (){
return 0;
}

does not work.

I just tried it.
4. When I change the return type of main to int or integer I get a mistake


You get a mistake? What does that mean? =x

main should be returning an int. Always:

1
2
3
4
int main() // can't forget the 'int'
{
//...
}


What error do you get when you do that?

EDIT: doh, too slow.

My question still stands though. What error do you get when you put int main
Last edited on
1>------ Build started: Project: ThirdLedaFactorial, Configuration: Debug Win32 ------
1>Compiling...
1>Third.cpp
1>Linking...
1>Third.obj : error LNK2019: unresolved external symbol "public: __thiscall leda::memory_manager_init::memory_manager_init(void)" (??0memory_manager_init@leda@@QAE@XZ) referenced in function "void __cdecl leda::`dynamic initializer for 'memory_mgr_init''(void)" (??__Ememory_mgr_init@leda@@YAXXZ)
1>Third.obj : error LNK2019: unresolved external symbol "public: __thiscall leda::memory_manager_init::~memory_manager_init(void)" (??1memory_manager_init@leda@@QAE@XZ) referenced in function "void __cdecl leda::`dynamic atexit destructor for 'memory_mgr_init''(void)" (??__Fmemory_mgr_init@leda@@YAXXZ)
1>F:\MyWork\Visual Studio 2008\Projects\ThirdLedaFactorial\Debug\ThirdLedaFactorial.exe : fatal error LNK1120: 2 unresolved externals
1>Build log was saved at "file://f:\MyWork\Visual Studio 2008\Projects\ThirdLedaFactorial\ThirdLedaFactorial\Debug\BuildLog.htm"
1>ThirdLedaFactorial - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
How do you compile it?? Makefile??
I use Build in VS
Ok... What's up with the Third.cpp?? Did you write that??...
Seems to have some errors in it...

Or start a new project from scratch just with the
1
2
3
4
int main()
{
    return 0;
}


This has to work!!! ;-)
Are you linking that library properly? Have you added it to the libs and includes directories in VS?
Everything is compiling fine when you have int main. The problems you're having are Linker errors are are related to this LEDA lib you're using.

You're #including the LEDA headers which is good, but you're not linking to the LEDA library, which is why you're getting the above "unresolved external symbol" error.

Now I'm not familiar with this library so I can't tell you exactly how to link to it, but there's typically a .lib file that comes with it. You would add this to the linked-to libs in your project settings.

Once you link to it properly, these errors will go away.
As soon as I make any reference to LEDA I get a memory manager error
filipe wrote:
Have you added it to the libs and includes directories in VS?
Disch wrote:
there's typically a .lib file that comes with it. You would add this to the linked-to libs in your project settings.
Topic archived. No new replies allowed.