LinuxQuestions.org
Visit Jeremy's Blog.
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 07-27-2004, 03:17 PM   #1
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
Communication between programs


I have programmed in different
languages (nasm: hardware driver and math routines,
c++: frontend-QT, (pascal: normal code -could be written in nasm- ) ).
So I have at least two different objectfiles, those I wanted to link together
but I don't know how I can get the same variable-name (a.out and nasm.o; both elf) in the same section (section.data) in gcc. - To link them together, to use that one variable in both object-files.

Or should I write a third program to execude both programs
and initialize Pipes ?
Under Linux there is a systemcall called set_thread_area,
Is that a possibility ?

I hope there is somebody with a standard solution.
The communication have to be in both directions !
 
Old 07-27-2004, 03:29 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
What you can do is is create your nasm.o and then when you compile the C++ program do g++ myprog.cpp nasm.o -o myprog

Or you can do g++ myprog.cpp -c which won't link the program, just create myprog.o. Then you can use ld to link myprog.o and nasm.o into the final executable by doing ld -o myprog myprog.o nasm.o

Last edited by itsme86; 07-27-2004 at 03:34 PM.
 
Old 07-27-2004, 04:14 PM   #3
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Original Poster
Rep: Reputation: 22
O.K. that I have done all.
My problem is to use a variable that's the same in both
object-files. ld uses only one offset if it sees, that 2 variables in a section
have the same name.
But I can't get gcc to write that variable name in a section (section.data or .bss).

I'm not really a c++ programmer (it's too complicaded). Assembler (NASM) is my favor.

Last edited by bastl; 07-27-2004 at 04:19 PM.
 
Old 07-27-2004, 04:45 PM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
In the C++ program, try declaring the variable as 'extern' (i.e. extern int somenum.

This tells the compiler or linker or something that the variable is actually declared in another file somewhere.

If that doesn't work, I have no idea.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
communication between threads alaios Programming 9 07-15-2005 04:39 PM
Stop communication otisthegbs Linux - Wireless Networking 2 12-09-2004 08:01 PM
Process Communication erdemilhan Programming 1 11-27-2004 04:06 PM
Communication via lan paulmedic555 Linux - Networking 1 11-03-2004 05:34 PM
communication redirection chtthies Linux - Newbie 1 11-11-2003 08:33 PM

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

All times are GMT -5. The time now is 01:53 AM.

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