03-02-2011
Quote:
Originally Posted by
dorik
Nope, just a class declaration. When I had it working by including the definitions in the project and the library, I set the static variable in the project and didn't set it in the library.
I really don't think you can make
one member of a class be exported from the code into the library, and the rest
exported from the library to the code. The whole thing gets instantiated as one 'thing'.
It
might work if you make it a global variable instead of a member, but you'll have to do it backwards from the rest of the library: In the shared library, it'll be an
extern "C" whatever *variable; and in your library-using code it's
extern "C" { whatever *variable=stuff; } That'd definitely work with static linking. Dynamic I'm less sure: It might demand that the variable actually exists to be able to create the shared library.
Quote:
Instead of including the definitions in both, I'd like to try the other approach I mentioned (exporting dynamic symbols in the project).
That exports
your code's symbols. Not the universe.
You might just have to add a call to set the static member.
Last edited by Corona688; 03-02-2011 at 12:03 PM..
This User Gave Thanks to Corona688 For This Post:
10 More Discussions You Might Find Interesting
1. Programming
Hi,
I have been trying to create a sharef object on my HP UX 11 machine
(HP-UX <myhostname> B.11.00 A 9000/879 ...... two-user license)
to create the shared object first I am creating the object file using
cc -Aa -c +z dyn.c
(I use -Aa and +z as per HP's manual on linkers ) to create the... (0 Replies)
Discussion started by: linuxpenguin
0 Replies
2. Linux
Hi All,
I created the share object file using
gcc -shared -fpic mypp.cpp -o myp.so
but, pls tell me how to link this .so file to my client program.
Thanks (0 Replies)
Discussion started by: sarwan
0 Replies
3. AIX
Hi,
When using shared objects on AIX 4.3 i am getting runtime problems.
I have a small sample program which links to a shared object libray, oracle and system related libraries.
At runtime it fails (gives segmentation fault and coredump ) in one proc file when executing login statement.
But... (0 Replies)
Discussion started by: suman_jakkula
0 Replies
4. Programming
Hi
I have a multithreaded daemon(server) which will accept connections from various clients and sends back results to them.
In order to serve my daemon clients, it has to establish a TCP connection to another server(vendor supplied which is listening on a specific TCP port) and gets the... (11 Replies)
Discussion started by: axes
11 Replies
5. UNIX for Advanced & Expert Users
Hi All,
I have a problem with the shared objects setup in AIX. We have a customized shell written by the developers over here. When i issue a MQ Series command (mqsilist) it is giving the error as . All the commands making use of this libImbCmdLib.a.so is failing. But when executed in normal... (1 Reply)
Discussion started by: dhanamurthy
1 Replies
6. Shell Programming and Scripting
Hi,
I have created a shared object (abc.so) which has a function sum(int a, int b).
Is there any way to load the "abc.so" and use the sum function using shell script..
thanks in advance (2 Replies)
Discussion started by: yhacks
2 Replies
7. AIX
Hi all,
I am developing an application with two components. One "c" binary and one "C++" shared object.
While execution, the shared object crashes out and core dump is created whenever "new" is executed. But if i use malloc this will work perfectly.
I tried to use dbx. Below given was... (1 Reply)
Discussion started by: itssujith
1 Replies
8. Programming
Hello,
While running a c++ shared object on AIX I am facing below error -
rtld: 0712-001 Symbol __ct__3ETDFv was referenced
from module /bancs/aml/lib/libmonitor.so(), but a runtime definition
of the symbol was not found.
rtld: 0712-001 Symbol etd_insert__3ETDFv was... (3 Replies)
Discussion started by: yatrik007
3 Replies
9. Red Hat
Hi,
I would like to create a shared object ( .so).
This shared object
1. uses the functions from a library.
2. Also it should be able to use the global variable in an app
To achieve this what should I do ? 1) To use the functions in the library should I give the -ld option while... (1 Reply)
Discussion started by: rvan
1 Replies
10. Programming
Hello,
I am not that experienced with Linux, and I am currently facing some issues.
The application I'm working on uses hundreds of threads. To optimize the memory usage, I am putting all my data inside a shared object (so).
The steps for this are as follows:
1. a C file (generated... (17 Replies)
Discussion started by: Maelstrom
17 Replies
LEARN ABOUT OSF1
__istart
end(3) Library Functions Manual end(3)
NAME
end, _end, _ebss, etext, _etext, edata, _edata, eprol, _ftext, _fdata, _fbss, _procedure_table, _procedure_table_size, _proce-
dure_string_table, __istart, __fstart, _DYNAMIC, _DYNAMIC_LINK, _BASE_ADDRESS, _GOT_OFFSET, _cobol_main - locations in program and defini-
tions in runtime procedure table
SYNOPSIS
extern unsigned long end; extern unsigned long _end; extern unsigned long _ebss;
/* First address above a program's */
/* uninitialized data region */
extern unsigned long etext; extern unsigned long _etext;
/* First address above the text region */
extern unsigned long edata; extern unsigned long _edata;
/* First address above the initialized */
/*data region */
extern unsigned long eprol;
/* First instruction of the user's program */
/* that follows the runtime startup routine */
extern unsigned long _ftext;
/* Start address of the text region */
extern unsigned long _fdata;
/* First address of the initialized data */
/* region */
extern unsigned long _fbss;
/* Start address of the uninitialized data */
/* region */
extern unsigned long _procedure_table; extern unsigned long _procedure_table_size; extern unsigned long _procedure_string_table;
/* See under DESCRIPTION */
extern unsigned long __istart;
/* Start address of the program's */
/* initialization function driver routine */
extern unsigned long __fstart;
/* Start address of the program's */
/* termination function driver routine */
extern unsigned long _DYNAMIC;
/* Address of a shared object's dynamic */
/* header table */
extern unsigned long _DYNAMIC_LINK;
/* Identifies the link type of a program */
/* or shared library. 0 for non_shared, */
/* 1 for call_shared and 2 for shared */
extern unsigned long _BASE_ADDRESS;
/* First mapped address of a program or */
/* shared library */
extern unsigned long _GOT_OFFSET;
/* Address of the global offset table in */
/* a shared program or shared library */
extern unsigned long _cobol_main
/* Address of the main routine in a cobol */
/* program */
DESCRIPTION
These names refer neither to routines nor to locations with interesting contents except for _procedure_table, _procedure_string_table, and,
for Tru64 UNIX, __istart and __fstart. Except for eprol, these are all names of linker-defined symbols.
Note that the end, etext, and edata symbols are not defined when you compile in ANSI mode.
When execution begins, the program break coincides with _end, but it is reset by the routines brk(2), malloc(3), standard input/output, the
profile (-p) option of cc(1), etc. The current value of the program break is reliably returned by "sbrk(0)"; (see brk(2)).
The linker-defined symbols _procedure_table, _procedure_table_size, and _procedure_string_table refer to the data structures of the runtime
procedure table. Because these are linker-defined symbols, the data structures are built by ld(1) only if they are referenced.
See the include file sym.h for the definition of the runtime procedure table, and see the include file exception.h for its uses.
These symbols are all absolute symbols; the value of each symbol is its address (for example, "&_procedure_table_size"). Any reference to
the symbol itself will attempt to access the symbol's value as if it were a valid address and will most likely result in an access viola-
tion.
All of these symbols except for end, _end, eprol, __istart, and _cobol_main are defined as local symbols in an executable or shared
library's dynamic symbol table. Consequently, an executable or shared library can only reference its own definitions of these local sym-
bols.
RELATED INFORMATION
brk(2), malloc(3). delim off
end(3)