LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-07-2005, 01:01 PM   #31
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32

That looks like a linker error. You might want to start a new thread though, now that you're no longer asking about which GUI API to use. You'll likely get more help with a new thread named something like, "X11 linking error, undefined reference".

> I have no idea of how makefiles works...

The LIBS line sets up a variable named LIBS and contains the string "-lXt -lX11 -lXext" (without the quotes, of course). You should add your "-L/usr/X11R6/lib" right before the "-lXt" and then remove the '-L....' from that gcc line.

I think your linker problem stems from trying to compile CDisplay.cpp with the gcc command. You want to use g++ instead for C++ files (while still using gcc for C files).

Though, it may also be that you need to add more libs to your LIBS variable. The headers that you include in your source file determine which libs you need to link in to your app. There are a number of X libs (they're fairly compartmentalized). If you indeed need to add more libs but don't know which ones to add, you could ask here (in a different thread, possibly entitled, "which Xlibs do I need to link in?").

Edit your makefile to look like this:

Code:
# Set up some variables for the rest of the makefile.
LIBS = -L/usr/X11R6/lib -lXt -lX11 -lXext
APP = CXtest

# The CXtest app depends on the CDisplay.o and cxapi.o files (you need
# those to be already built before building CXtest).
# If CXtest is older than either of those object files, rebuild CXtest using
# the command on the next line after the tab.
${APP}: CDisplay.o cxapi.o
    g++ -o ${APP} CDisplay.o cxapi.o ${LIBS}

# Rebuild CDisplay.o if CDisplay.cpp is newer that it is. (i.e. If you've
# modified CDisplay.cpp since the last time CDisplay.o was built, rebuild
# CDisplay.o with the g++ command on that line starting with a tab char).
CDisplay.o: CDisplay.cpp
    g++ -c CDisplay.cpp

# By now you're getting how this works. :)
cxapi.o: cxapi.c
    gcc -c cxapi.c
Note:

1. You'll need to use tabs instead of spaces in front of those gcc and g++ lines. g++ is just a C++ -specific front-end to gcc.

2. You may need to change that last 'gcc' to 'g++' -- dunno. Give it a try. I think it's most common to just use g++ for everything (instead of gcc) if you have any C++ in your program.

---J

Last edited by johnMG; 03-07-2005 at 01:04 PM.
 
  


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
Smtp C Api cecilcosta Linux - Networking 2 01-05-2005 08:07 AM
Socket API shy Programming 2 10-23-2004 01:32 PM
libxcrypt API tmakobu Programming 1 02-25-2004 06:53 PM
What is the VMA API? KillerFry Linux - General 1 09-16-2003 05:05 PM
API handling KaktusKnight Linux - General 0 03-14-2003 06:25 AM

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

All times are GMT -5. The time now is 11:24 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