473,383 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

undefined reference to `_WinMain@16' related to Namespace STD?

Hello Everyone,

I am currently using eclipse to try and do some pretty basic C++. When I was trying to configure I noticed G++ was giving me an error. When I troubleshot the problem I found that if I added the namespace std it would compile fine. Why is this?

Code with namespace:
Expand|Select|Wrap|Line Numbers
  1. #include "TestClass.h"
  2. using namespace std;
  3.  
  4. TestClass::TestClass()
  5. {
  6. }
  7.  
  8. TestClass::~TestClass()
  9. {
  10. }
  11. int main() 
  12. {
  13.     return 0;
  14. }
  15.  
Compiling messages without:
**** Clean-only build of configuration Release for project UseDLL ****
Build complete for project UseDLL

**** Build of configuration Release for project UseDLL ****

make all
Building file: ../src/DllTest.cpp
Invoking: Cygwin C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/DllTest.d" -MT"src/DllTest.d" -o"src/DllTest.o" "../src/DllTest.cpp"
Finished building: ../src/DllTest.cpp

Building target: UseDLL.exe
Invoking: Cygwin C++ Linker
g++ -o"UseDLL.exe" ./src/DllTest.o
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
make: *** [UseDLL.exe] Error 1
Aug 21 '07 #1
1 7487
Banfa
9,065 Expert Mod 8TB
Building target: UseDLL.exe
Invoking: Cygwin C++ Linker
g++ -o"UseDLL.exe" ./src/DllTest.o
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../libcygwin.a(libcmain.o):(.text+0xab): undefined reference to `_WinMain@16'
collect2: ld returned 1 exit status
make: *** [UseDLL.exe] Error 1
This error is nothing to do with namespace standard.

You have told the linker that you are compiling a windows program (through the use of switches on your command line). The entry point for Windows programs is WinMain, however you have provided main which is the entry point for console programs (on a windows system) and ANSI C programs.
Aug 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Daniel Heiserer | last post by:
Hi, I got the following compiling/linking error, but I have no clue what it is about. Can anybody help me? thanks, daniel
2
by: RU | last post by:
Hi, I am working on a porting project to port C/C++ application from unixware C++, AT&T Standard components to g++ with STL on Linux. This application has been working properly on...
10
by: siroregano | last post by:
Hello- I've got a nice C program written that uses libsndfile (#include <sndfile.h>) to convert my raw data into a properly-formatted wav file. The program is composed of a single .c file that...
40
by: vfunc | last post by:
I get an undefined reference error for a definition that clearly looks like it is in a .h file. So what can be the cause of an undefined reference error, when this .h file containing the...
3
by: s.z.s | last post by:
Hi! I hope the solution to that is not too stupid... I've got three files: <snip test_main.cc> #include"test.hh" int main(void) { A<inta1; a1.saywhat();
3
by: prakash.mirji | last post by:
Hello, I am getting below mention linker error when I tried to link my class test.C I use below command to compile test.C /usr/bin/g++ -g -fpic -fvisibility=default -D_POSIX_SOURCE...
1
by: taiyang902 | last post by:
i program under linux ,and using kdevelop c/c++. the code follow, #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <iostream> #include <cstdlib> using namespace std;
8
Motoma
by: Motoma | last post by:
Good evening everyone. I am starting to re-explore C++, and I wanted to build a singleton class. Unfortunately, when I set things up as I do in PHP, it doesn't work out for me. I hope that the...
3
by: chaturap | last post by:
Hi, I'm trying to implement factory method pattern using C++ on Ubuntu 8.04 using gcc 4.2. There are 3 major classes DBConnectionFactory, DBConnector and OracleConnector (which is the derived...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.