473,388 Members | 1,309 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,388 software developers and data experts.

c++ compilation problem

I have this problem whenever I try to compile a very trivial program:

[mmfernan@algopc151 HelloWorld]$ cc -G HelloWorld.c -o libHelloWorld.so
cc: unrecognized option '-G'
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status

[mmfernan@algopc151 HelloWorld]$ cc -g HelloWorld.c -o libHelloWorld.so
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status

Do you have an idea?

thanks

Marcelo
Sep 14 '05 #1
5 11149
Marcelo wrote:
I have this problem whenever I try to compile a very trivial program:

[mmfernan@algopc151 HelloWorld]$ cc -G HelloWorld.c -o libHelloWorld.so
cc: unrecognized option '-G'
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status

[mmfernan@algopc151 HelloWorld]$ cc -g HelloWorld.c -o libHelloWorld.so
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status

Do you have an idea?


Only if you post the very trivial program, do you think we are psychic?

BTW this is a linking error not a compiler error. You could have made a
mistake in your program, but I think it is more likely you have made a
mistake in the compiler options you are using. But that would be a
compiler issue not a C++ issue.

john
Sep 14 '05 #2
You were trying to make an so file. Try '-shared -fpic'
And pls post your program next time no matter how trivial it is.

Sep 14 '05 #3
Marcelo wrote:
I have this problem whenever I try to compile a very trivial program:

[mmfernan@algopc151 HelloWorld]$ cc -G HelloWorld.c -o libHelloWorld.so
This compiles C, not C++.
cc: unrecognized option '-G'
What is the -G supposed to do? According to the manual page, this option is
specific to the "Renesas M32R/D" architecture. Are you sure you're
compiling for that architecture?
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status


Well, it seems you are trying to create a shared library. But how is the
compiler supposed to know that if you don't tell it? It's searching for
your definition of a main() function because it wants to build an
executable.
How about reading your linker's documentation?

Sep 14 '05 #4
na******@gmail.com wrote:
You were trying to make an so file. Try '-shared -fpic'
And pls post your program next time no matter how trivial it is.

Thanks man, it works when i put -shared. I am very new in this c++
world, but I like it. (I am trying to use the JNI between java and c++).

Thanks a lot

Marcelo
Sep 15 '05 #5
Marcelo wrote:
I have this problem whenever I try to compile a very trivial program:

[mmfernan@algopc151 HelloWorld]$ cc -G HelloWorld.c -o
libHelloWorld.so cc: unrecognized option '-G'
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
function `_start':
undefined reference to `main'

collect2: ld returned 1 exit status

[mmfernan@algopc151 HelloWorld]$ cc -g HelloWorld.c -o
libHelloWorld.so
/usr/lib/gcc/i386-redhat-linux/4.0.0/../../../crt1.o(.text+0x18): In
function `_start':
undefined reference to `main'

collect2: ld returned 1 exit status

Do you have an idea?


Not sure what you're trying to do, but 'main' is a function every program
should contain to be a complete C++ program. Yours probably doesn't have
it. That's what the linker (ld) complains about.

V
Sep 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Alex Vinokur | last post by:
Hi, The code below has no problem with GNU g++ 3.3, but it has a problem with GNU g++ 3.4. What is reason for that? --------- foo.cpp : BEGIN --------- template <typename T> struct Boo
6
by: Joachim | last post by:
I made some project changes (which seems it doesn't help if I undo) which have created compilation error: " Server Error in '/PCSWebApp1' Application....
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
10
by: RedEagle | last post by:
Hi All! Do you remember me? I am that desperate who had this error for a while: --- Compilation Error Description: An error occurred during the compilation of a resource required to service...
0
by: Mythran | last post by:
I'm have 2 primary errors that seem to occur. 1.) In my ASP.Net application, I have 3 libraries (BLL, DAL, and Schema) that are used for the 4th and 5th UI libraries. All of the dependant...
3
by: seema | last post by:
Hi all, I am new to C programming. I have problem compiling a sample , #include <stdio.h> int getuniqueaddress1(){ return 1; } int getuniqueaddress2(){ return 2;
4
by: Bob | last post by:
Hi, In VS2003 conditional compilation constants and their state could be defined at project level. I was using this to control what features where offered by various builds. i.e....
35
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files....
6
by: maxwell | last post by:
I'm trying to use the gpp utility (Gnu points to http://en.nothingisreal.com/wiki/GPP) to do conditional compilation in Python, and I'm running into a problem: the same '#' character introduces...
1
by: Alex Vinokur | last post by:
Hi, I have compilation problem on SUN CC compiler with template while using option -m64 (64-bit addressing model). No problem while using option -m32 (32-bit addressing model) $ CC -V CC:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.