LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2014, 05:53 PM   #1
djohan
LQ Newbie
 
Registered: Oct 2014
Location: La Honda, California
Distribution: Red Hat 9.0, Precise Puppy 5.7.1
Posts: 12

Rep: Reputation: Disabled
Question Compiling C with gcc


My C program (XM3DEDIT) has numerous gtk,gdk,X11 library calls. I am compiling from PUPPY console. The program has previous compile and run
history from RedHat 9.0 all OK. The compiled program also runs fine on PUPPY. But the command:

# gcc `pkg-config --cflags --libs gtk+-2.0` 00XM3DEDIT.c -o XM3DEDIT

produces numerous dependency errors. It is latest gcc and seems OK.

Q1: What are correct #include(s) to fold in the dependents.

Q2: What is correct command line to replace gcc arguments above.

Thanks,

djohan
 
Old 10-21-2014, 10:42 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
you do know that RH9 is almost like Windows 98 , same era win98/xp( no sp)

if the code was for rh9
that is the 2.4 kernel
that was replaced a long time ago by the 2.6

there is NO operating susyem that will be easly to build code for rh9

it is like trying to build win98 16 bit code on a win8 computer
-- will not work out well

this post also is VERY close to this ubuntu post
http://askubuntu.com/questions/53864...-4-lts-desktop


you can "try" ???? to build it
but you wil need some VERY old code and antique programs
to start with gcc 2.9 or OLDER
then the VERY OLD gtk1 ( gtk3 is the current)
 
Old 10-21-2014, 11:12 PM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
You might want to quote the error messages (at least the first few (not the last ones!)), for those who aren't clairvoyants.

Since then even the linker's behaviour has been changed, try this:

Code:
# gcc `pkg-config --cflags gtk+-2.0` 00XM3DEDIT.c -o XM3DEDIT `pkg-config --libs gtk+-2.0`

Last edited by NevemTeve; 10-21-2014 at 11:21 PM.
 
1 members found this post helpful.
Old 10-22-2014, 12:49 PM   #4
djohan
LQ Newbie
 
Registered: Oct 2014
Location: La Honda, California
Distribution: Red Hat 9.0, Precise Puppy 5.7.1
Posts: 12

Original Poster
Rep: Reputation: Disabled
Wink Revised Command Tried

Quote:
Originally Posted by NevemTeve View Post
You might want to quote the error messages (at least the first few (not the last ones!)), for those who aren't clairvoyants.

Since then even the linker's behaviour has been changed, try this:

Code:
# gcc `pkg-config --cflags gtk+-2.0` 00XM3DEDIT.c -o XM3DEDIT `pkg-config --libs gtk+-2.0`
From djohan: Adding the linker reduced messages from about 200 to 4 (3 warnings +1 error).
The error msg was:

/usr/bin/ld: /tmp/cc4rz1DJ.o undefined reference to symbol 'atan2@@GLIBC_2.0'
/usr/bin/ld: note: 'atan2@@GLIBC_2.0' is defined in DSO /lib/libm.so.6 so try
adding it to the linker command line
/lib/libm.so.6: could not read symbols: Invalid operation
collect2: 1d returned 1 exit status

Note: Followed the instructions above (Put /lib/libm.so.6 inside linker quotes) and compiled with only three warnings. But new error message was:

/usr/bin/1d: cannot open output file XM3DEDIT: No such file or directory
collect2: 1d returned 1 exit status

Last edited by djohan; 10-22-2014 at 01:46 PM. Reason: Error #1 was fixed, New error occurred.
 
Old 10-22-2014, 01:13 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
as per the error
and the possible fix it told you
did you try adding libm ????

Code:
gcc `pkg-config --cflags gtk+-2.0` 00XM3DEDIT.c -o XM3DEDIT `pkg-config --libs -lm gtk+-2.0`
but this is old rh9 code
do not expect it to work on a modern OS

Last edited by John VV; 10-22-2014 at 01:14 PM.
 
Old 10-23-2014, 01:04 AM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
I'd reorder it, putting -lm to the end:

Code:
gcc `pkg-config --cflags gtk+-2.0` 00XM3DEDIT.c -o XM3DEDIT \
    `pkg-config --libs   gtk+-2.0` -lm
 
Old 10-23-2014, 04:42 AM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Quote:
/usr/bin/1d: cannot open output file XM3DEDIT: No such file or directory
collect2: 1d returned 1 exit status
Quote the actual message, not only type in what you see/remember (1d and ld are different)
 
1 members found this post helpful.
Old 10-23-2014, 02:13 PM   #8
djohan
LQ Newbie
 
Registered: Oct 2014
Location: La Honda, California
Distribution: Red Hat 9.0, Precise Puppy 5.7.1
Posts: 12

Original Poster
Rep: Reputation: Disabled
Wink XM3DEDIT Compiled and Ran

The gcc command compiled as follows:

gcc `pkg-config --cflags --libs gtk+-2.0` 00XM3DEDIT.c -o XM3DEDIT \
`pkg-config --libs gtk+-2.0` -lm

Compile was clean with no warnings or errors. XM3DEDIT runs OK so far.

My console doesn't provide select/copy of text so above was typed in (beware!).
Also backslash should be dropped.
Thanks, Don
 
Old 10-27-2014, 04:02 AM   #9
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Off: The backslash at the end of a line means continuation line follows
Off2: In X Window System, you can use left mouse button to select text, right/middle button to paste the selected test.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in compiling gcc-3.3.3 with gcc-4.3.2 asahlot Linux - Software 6 02-08-2009 11:25 AM
How to selectively use GCC 3.4 -OR- GCC 4.1 in FC6 when compiling? rylan76 Fedora 2 11-21-2006 11:36 PM
Error compiling gcc 3.3.6 with 64bit gcc 4.0.3 cs-cam Linux - Software 0 04-22-2006 05:20 AM
Kernel compiling: gcc-3.3 is 586, should be gcc-3.3 386 Erik Plaggenmar Linux - Software 0 10-01-2004 11:38 AM
Various Compiling Errors (GCC compiling Openal, GUIlib, xmms-wma) gregorya Linux - Software 2 08-27-2004 05:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration