Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

make can't find main

51 views
Skip to first unread message

Popping mad

unread,
Nov 19, 2016, 1:05:10 PM11/19/16
to
When I did the mock up test example for the question on static vars,
I've run into a compiler issue I've never seen before and I haven't
been able to find a fix. I'm getting an error that says

[ruben@flatbush test_static]$ make
g++ -Wall -ggdb -pg -pthread -o testme test.o main.o
/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib/gcrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [makefile:7: testme] Error 1

makefile

1 CXX:=g++
2 CXXFLAGS:=-Wall -ggdb -pg -pthread
3
4 LDFLAGS:=-L/usr/local/lib/mysql -lmysqlpp -lmysqlclient
5
6 testme : test.o main.o
7 ${CXX} ${CXXFLAGS} -o $@ test.o main.o
8
9 main.o : main.cpp
10 ${CXX} ${CXXFLAGS} -o $@ -c main.cpp
11
12
13 testo : test.cpp test.h
14 ${CXX} ${CXXFLAGS} -o $@ -c test.cpp
15
16 clean :
17 rm testme *.o make.deps
18 touch *.cpp *.h
19
20 include make.deps
21 make.deps: *.cpp ; gcc -M *.cpp >$@
~

test.cpp

18 #include "test.h"
19 #include <iostream>
20 namespace blah{
21 int A::here;
22 void A::read(int in){
23 A::here = in;
24 std::cout << A::here << std::endl;
25 }
26 }

~

test.h

1 namespace blah{
2 class A{
3 public:
4 static int here;
5 A(int in=0){
6 here = in;
7 };
8 void read(int);
9 };
10
11 }
~
main.cpp
:w
18 #include "test.h"
19 #include <iostream>
20 namespace std{
21
22 int main(int argc, char** argv){
23 blah::A* a = new blah::A{9};
24 cout << a->here << endl;
25 return 0;
26 }
27
28 }

Louis Krupp

unread,
Nov 19, 2016, 1:31:33 PM11/19/16
to
On Sat, 19 Nov 2016 18:04:50 +0000 (UTC), Popping mad
<rai...@colition.gov> wrote:

>When I did the mock up test example for the question on static vars,
>I've run into a compiler issue I've never seen before and I haven't
>been able to find a fix. I'm getting an error that says
>
>[ruben@flatbush test_static]$ make
>g++ -Wall -ggdb -pg -pthread -o testme test.o main.o
>/usr/lib/gcc/x86_64-pc-linux-gnu/6.2.1/../../../../lib/gcrt1.o: In function `_start':
>(.text+0x20): undefined reference to `main'
>collect2: error: ld returned 1 exit status
>make: *** [makefile:7: testme] Error 1
<snip>
>main.cpp
>:w
> 18 #include "test.h"
> 19 #include <iostream>
> 20 namespace std{
> 21
> 22 int main(int argc, char** argv){
> 23 blah::A* a = new blah::A{9};
> 24 cout << a->here << endl;
> 25 return 0;
> 26 }
> 27
> 28 }

It looks like you're defining 'std::main' instead of 'main'. Try
this:

18 #include "test.h"
19 #include <iostream>
20 using namespace std;
21
22 int main(int argc, char** argv){
23 blah::A* a = new blah::A{9};
24 cout << a->here << endl;
25 return 0;
26 }

Louis

ruben safir

unread,
Nov 19, 2016, 3:57:02 PM11/19/16
to
that work, but it is disappointing. How can main exist out of a namespace?

Dombo

unread,
Nov 19, 2016, 4:52:39 PM11/19/16
to
Op 19-Nov-16 om 21:56 schreef ruben safir:
> that work, but it is disappointing. How can main exist out of a namespace?

In this case the main() function ends up in the global namespace, and
that is where the linker expects to find it.

Unless you explicitly specify otherwise functions, classes..etc end up
in the global namespace, which is perfectly legal in C++.

Generally it is not a good idea to put things in the std namespace like
you tried to do with the main() function. The std namespace is intended
for the standard library. If you put things in the std namespace you
might get conflicts with future versions of the standard library.


Louis Krupp

unread,
Nov 19, 2016, 4:59:37 PM11/19/16
to
On Sat, 19 Nov 2016 15:56:54 -0500, ruben safir <ru...@mrbrklyn.com>
wrote:
It doesn't. It's in the global namespace.

See https://msdn.microsoft.com/en-us/library/5cb46ksf.aspx.

Louis

Popping mad

unread,
Nov 19, 2016, 5:37:39 PM11/19/16
to
On Sat, 19 Nov 2016 14:57:12 -0700, Louis Krupp wrote:


> It doesn't. It's in the global namespace.
>
> See https://msdn.microsoft.com/en-us/library/5cb46ksf.aspx.


can't reach a microsoft site. I think it is /dev/null routed.

Do you can a C++ link? or a GCC?

Alf P. Steinbach

unread,
Nov 19, 2016, 7:05:34 PM11/19/16
to
Check out the SO C++ book list if you don't have a textbook.

You can just google that term.

I would suggest that you get yourself also a copy of a draft of the C++
standard, even though the standard is written mainly for compiler
vendors and therefore is generally not very accessible to learners.


Cheers! & hth.,

- Alf

PS: Microsoft documentation includes numerous examples of `void main`,
which is non-standard, and the Visual Studio default code for a C++
project has a different non-standard main function. To top it off, in
their documentation they have falsely alleged, since the early 1990s!,
that one of their non-standard main functions is the program's entry
point, confusing themselves to the extent that other info has become
corrupted. Thus MS is not a good authority on the C++ main function.

woodb...@gmail.com

unread,
Nov 20, 2016, 10:51:13 AM11/20/16
to
On Saturday, November 19, 2016 at 6:05:34 PM UTC-6, Alf P. Steinbach wrote:
> On 19.11.2016 23:37, Popping mad wrote:
> > On Sat, 19 Nov 2016 14:57:12 -0700, Louis Krupp wrote:
> >
> >
> >> It doesn't. It's in the global namespace.
> >>
> >> See https://msdn.microsoft.com/en-us/library/5cb46ksf.aspx.
> >
> >
> > can't reach a microsoft site. I think it is /dev/null routed.
> >
> > Do you can a C++ link? or a GCC?
>
> Check out the SO C++ book list if you don't have a textbook.
>
> You can just google that term.
>

I suggest using Duckduckgo --https://duckduckgo.com

. They have better policies than Google.


Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net

woodb...@gmail.com

unread,
Dec 3, 2016, 1:54:10 PM12/3/16
to
On Saturday, November 19, 2016 at 6:05:34 PM UTC-6, Alf P. Steinbach wrote:
> On 19.11.2016 23:37, Popping mad wrote:
> > On Sat, 19 Nov 2016 14:57:12 -0700, Louis Krupp wrote:
> >
> >
> >> It doesn't. It's in the global namespace.
> >>
> >> See https://msdn.microsoft.com/en-us/library/5cb46ksf.aspx.
> >
> >
> > can't reach a microsoft site. I think it is /dev/null routed.
> >
> > Do you can a C++ link? or a GCC?
>
> Check out the SO C++ book list if you don't have a textbook.
>
> You can just google that term.
>

I suggest using an alternative to Google like
https://duckduckgo.com
. They don't keep track of your searches.


> I would suggest that you get yourself also a copy of a draft of the C++
> standard, even though the standard is written mainly for compiler
> vendors and therefore is generally not very accessible to learners.
>

This "Standard slam" video shows how lame the standard can be:

https://www.youtube.com/watch?v=ZLNq-4IiNTY&list=PLRyNF2Y6sca06lulacjysyu8RIwfKgYoY&index=15

David Brown

unread,
Dec 3, 2016, 4:48:28 PM12/3/16
to
On 03/12/16 19:54, woodb...@gmail.com wrote:
> On Saturday, November 19, 2016 at 6:05:34 PM UTC-6, Alf P. Steinbach wrote:
>> On 19.11.2016 23:37, Popping mad wrote:
>>> On Sat, 19 Nov 2016 14:57:12 -0700, Louis Krupp wrote:
>>>
>>>
>>>> It doesn't. It's in the global namespace.
>>>>
>>>> See https://msdn.microsoft.com/en-us/library/5cb46ksf.aspx.
>>>
>>>
>>> can't reach a microsoft site. I think it is /dev/null routed.
>>>
>>> Do you can a C++ link? or a GCC?
>>
>> Check out the SO C++ book list if you don't have a textbook.
>>
>> You can just google that term.
>>
>
> I suggest using an alternative to Google like
> https://duckduckgo.com
> . They don't keep track of your searches.
>

Or you can google the term - because Google is a better search engine
than duckduckgo or any other general purpose web search. It gives you
better results partly because they throw more resources at it, and
partly because they track your searches so that their engine can learn
from both you and other people.

Duckduckgo is a marvellous choice if you want to search for pictures of
naked mud-wrestlers without anyone following your trail, or if you are
hiding from the CIA. But for most information, google is the sensible
choice for the non-fanatic.

>
>> I would suggest that you get yourself also a copy of a draft of the C++
>> standard, even though the standard is written mainly for compiler
>> vendors and therefore is generally not very accessible to learners.
>>
>
> This "Standard slam" video shows how lame the standard can be:
>
> https://www.youtube.com/watch?v=ZLNq-4IiNTY&list=PLRyNF2Y6sca06lulacjysyu8RIwfKgYoY&index=15
>

You do know that Google owns YouTube, and tracks which videos you watch?
If you are not careful, it will compile enough information about you
to recommend other C++ videos to you rather than Katty Perry tracks and
funny cat videos.


Chris Vine

unread,
Dec 3, 2016, 6:54:00 PM12/3/16
to
On Sat, 3 Dec 2016 10:54:01 -0800 (PST)
woodb...@gmail.com wrote:
[snip]
> > I would suggest that you get yourself also a copy of a draft of the
> > C++ standard, even though the standard is written mainly for
> > compiler vendors and therefore is generally not very accessible to
> > learners.
>
> This "Standard slam" video shows how lame the standard can be:
>
> https://www.youtube.com/watch?v=ZLNq-4IiNTY&list=PLRyNF2Y6sca06lulacjysyu8RIwfKgYoY&index=15

It is easy to try to make yourself appear clever by putting down
other people's efforts. Human beings have this tendency but you seem to
be especially good at it.

So you like to get off on criticizing others? Makes you feel better
about yourself? Makes you feel like less of a weirdo? It won't work.
Everyone on this newsgroup knows that your views are worthless.

You could not write a specification for a programming language to save
your life.

woodb...@gmail.com

unread,
Dec 3, 2016, 10:50:40 PM12/3/16
to
Some day people will admit that children are best served
by having both a father and a mother. I think it's my
defense of children that motivates some people to attack
me like this. They have gone astray and want others to
join them. I'm happy to fight for children's right to the
diversity of a father and a mother. As I've pointed out
before, two men don't even have breast milk for a baby.
There are physical, mental and spiritual differences between
men and women and I think children benefit from having both
of those perspectives.

I'm glad Michael Caisse gave that talk and that he got so
much applause at the end of the talk.

Also I'm glad there is a standard, and I hope that by the
grace of G-d I'll be able to help improve the standard in the
future -- your discouraging words notwithstanding. I did have
an idea a couple of years ago for improving the standard that
was discussed here. If I remember right, Alf said something
positive about the idea.

Brian
Ebenezer Enterprises
http://webEbenezer.net

ruben safir

unread,
Dec 4, 2016, 4:13:47 AM12/4/16
to
On 12/03/2016 04:48 PM, David Brown wrote:
> Or you can google the term - because Google is a better search engine
> than duckduckgo or any other general purpose web search. It gives you
> better results partly because they throw more resources at it, and
> partly because they track your searches so that their engine can learn
> from both you and other people.
>
> Duckduckgo is a marvellous choice if you want to search for pictures of
> naked mud-wrestlers without anyone following your trail, or if you are
> hiding from the CIA. But for most information, google is the sensible
> choice for the non-fanatic.

that's bullshit. They are actually both so bad now that the only
difference is that duckduckgo doesn't search you.

It used to be that duckduckgo was somewhat superior. But now they use
the bling engine.

The bottom line is that they all now are so bent are displaying products
to sell, that real information is getting harder and harder to find
outside of wikipedia, which sucks for its own reason.

Furthermore, finding information HAS ZERO to do with searching and
tracking. Its already an accomplished feat, maybe 15 years already.
The purpose of tracking you is to monetarise you and so that they can
have control of you....PERIOD.

I can't believe that after all these years that, A) there are trolls
who enter threads dead for 2 weeks just to push their love for duck duck
go, and then other blowhards, even stupider, and likely on someones
payroll, to counter argue.


Anyway, they are both off topic, and one more outburst and you both go
/dev/null


ruben safir

unread,
Dec 4, 2016, 4:18:44 AM12/4/16
to
FOOOOMP /dev/null

fucking idiot

Popping mad

unread,
Dec 4, 2016, 4:23:42 AM12/4/16
to
that is your one fucking post and your not worried about tracking and
privacy? Yeeesh

Chris Vine

unread,
Dec 4, 2016, 4:35:27 AM12/4/16
to
You are incapable of applying logic. I have no idea what your views on
the bringing up of children are but it must be completely obvious that
my post had nothing to do with that. It was about your dismissive
attitude to the efforts of people who in fact know a lot more than you
do.

Given your difficulties with logic, your chances of improving the
standard are negligible.
0 new messages