Results 1 to 5 of 5
Hello All,
I have installed shmap library in which we can write into map through shared memory. I got it from open source. I wrote a program based on it's ...
- 10-16-2008 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 3
Regarding Shared Memory Problem
Hello All,
I have installed shmap library in which we can write into map through shared memory. I got it from open source. I wrote a program based on it's APIs. While compiling I am getting some linking errors. The description is below ...
LD_LIBRARY_PATH=/usr/local/lib/
PROGRAM : Shmap.cpp
-----------------------------------------
#include <iostream>
#include <string.h>
#include "/usr/local/include/shmap.h"
using namespace std;
int main()
{
shmap_opts *p_opts;
shmap *sample_map;
sample_map = shmap_init ( p_opts );
string name = "deepak";
char const *conv_name = name.c_str();
string value = "3";
char const *conv_value = value.c_str();
int add_chck = shmap_add_value ( sample_map, conv_name , conv_value);
cout<<"AFTER ADDITION VALUE = "<<add_chck<<endl;
void *get_chck;
int cached = 1;
get_chck = shmap_get_value( sample_map, conv_name, cached );
cout<<"VALUE GOT = "<<get_chck<<endl;
return 0;
}
--------------------------------------------------
COMPILATION
g++ Shmap.cpp -o Shmap
/tmp/cc6v4tBa.o: In function `main':
Shmap.cpp
.text+0x8b): undefined reference to `shmap_init(shmap_opts*)'
Shmap.cpp
.text+0x16b): undefined reference to `shmap_add_value(shmap*, char const*, char const*)'
Shmap.cpp
.text+0x1c3): undefined reference to `shmap_get_value(shmap*, char const*, int)'
collect2: ld returned 1 exit status
Can anybody guide me on this ???
- 10-16-2008 #2Just Joined!
- Join Date
- Feb 2008
- Posts
- 50
The compiler not getting your installed library path.
you can specify path by,
LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH <new library path>
or you can specify new library path by, -L and name of library by -l with gcc like this;
g++ Shmap.cpp -o Shmap -L <lib path> -l<libname>
read gcc man page for more.
- 10-16-2008 #3Just Joined!
- Join Date
- Jun 2008
- Posts
- 3
I tried acoording to you
g++ Shmap.cpp -o Shmap -L /usr/local/lib/ -lshmap
but the problen remains same......
Can you help ???
- 10-16-2008 #4Just Joined!
- Join Date
- Feb 2008
- Posts
- 50
At Compile time, "shmap.h " lets the compiler know what the calling interface for each function in shmap library, so the compiler can compile your calls to that library correctly.
But at link time, linker needs access to the actual compiled library, otherwise your program doesn't include the shmap library.
If you have installed it correctly. It should be work.
add this in your command and make sure you install correctly.
g++ Shmap.cpp libgcc.a -o Shmap -L /usr/local/lib/ -lshmap
Also if it installed at standard location, you can remove -L option.
Hope this helps.
- 10-17-2008 #5Just Joined!
- Join Date
- Jun 2008
- Posts
- 3
Can please do me a favour ... ,the following link contains shmap library (SourceForge.net: Shared Memory Map) . It's a small library. Can you install it and check the issue with the above code I have written, I am new to this concept. Cant recognise the problem.


Reply With Quote