efficient / libcuckoo

A high-performance, concurrent hash table
Other
1.61k stars 275 forks source link

undefined reference when building a sharedlib #6

Closed yarf closed 9 years ago

yarf commented 9 years ago

please advise?

foo.cpp:

#include <libcuckoo/cuckoohash_map.hh>
#include <libcuckoo/city_hasher.hh>

typedef cuckoohash_map<int, int> Map;
Map map;

$ g++ -Wall -fPIC -std=c++11 -shared -o foo.so foo.cpp $ LD_PRELOAD=./foo.so someprocess $ symbol lookup error: ./foo.so: undefined symbol: _ZN14cuckoohash_mapIiiSt4hashIiESt8equal_toIiEE6Bucket13key_allocatorE

apc999 commented 9 years ago

hi Yarf,

(1) could you describe your system setting: e.g., OS and g++ version?

(2) under libcuckoo/examples/ , could you successfully "make" and run binaries like "hellohash" or "count_freq"?

Thanks,

On Sun, Mar 15, 2015 at 2:35 PM, yarf notifications@github.com wrote:

please advise?

foo.cpp:

include <libcuckoo/cuckoohash_map.hh>

include <libcuckoo/city_hasher.hh>

typedef cuckoohash_map<int, int> Map; Map map;

$ g++ -Wall -fPIC -std=c++11 -shared -o foo.so foo.cpp $ LD_PRELOAD=./foo.so someprocess $ symbol lookup error: ./foo.so: undefined symbol: _ZN14cuckoohash_mapIiiSt4hashIiESt8equal_toIiEE6Bucket13key_allocatorE

— Reply to this email directly or view it on GitHub https://github.com/efficient/libcuckoo/issues/6.

Computer Science Department Carnegie Mellon University

yarf commented 9 years ago

Hi Bin, and thanks for responding 1) g++ --version g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 same issue with clang++ too, btw 2) yes, and all the tests pass also

manugoyal commented 9 years ago

Hi yarf,

It seems like we forgot to externally declare some static variables in the cuckoohash_map class. I just pushed a commit that fixes that. Let me know if you're still having problems.

Thanks -Manu

On Sun, Mar 15, 2015 at 2:53 PM, yarf notifications@github.com wrote:

Hi Bin, and thanks for responding 1) g++ --version g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1 same issue with clang++ too, btw 2) yes, and all the tests pass also

On Sunday, March 15, 2015 2:48 PM, Bin Fan notifications@github.com wrote:

hi Yarf,

(1) could you describe your system setting: e.g., OS and g++ version?

(2) under libcuckoo/examples/ , could you successfully "make" and run binaries like "hellohash" or "count_freq"?

Thanks,

  • Bin

On Sun, Mar 15, 2015 at 2:35 PM, yarf notifications@github.com wrote:

please advise?

foo.cpp:

include <libcuckoo/cuckoohash_map.hh>

include <libcuckoo/city_hasher.hh>

typedef cuckoohash_map<int, int> Map; Map map;

$ g++ -Wall -fPIC -std=c++11 -shared -o foo.so foo.cpp $ LD_PRELOAD=./foo.so someprocess $ symbol lookup error: ./foo.so: undefined symbol: _ZN14cuckoohash_mapIiiSt4hashIiESt8equal_toIiEE6Bucket13key_allocatorE

— Reply to this email directly or view it on GitHub https://github.com/efficient/libcuckoo/issues/6.

Computer Science Department Carnegie Mellon University — Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHub https://github.com/efficient/libcuckoo/issues/6#issuecomment-81256296.

yarf commented 9 years ago

That appears to have done the trick -- thanks!

yarf commented 9 years ago

spoke too soon, though this is a different issue:

#include <libcuckoo/cuckoohash_map.hh>
#include <libcuckoo/city_hasher.hh>

typedef cuckoohash_map<int, int> Map;
Map map;

static void _construct() __attribute__((constructor));
static void _construct()
{
        printf ("{\n");
        map[0] = 1010;
        printf ("}\n");
}

$ g++ -Wall -fPIC -std=c++11 -shared -o foo.so foo.cpp $ LD_PRELOAD=./foo.so someprocess { Segmentation fault (core dumped)

I'm suspecting this may be due to constructor ordering ... any idea how to resolve?

manugoyal commented 9 years ago

I'm not sure this has to do with libcuckoo, it might be some weird c++ thing. When I compile the following file

include

static void _construct() attribute((constructor)); static void _construct() { std::cout << "hello" << std::endl; }

$ g++-4.8 -Wall -fPIC -std=c++11 -shared -o test.so test.cpp $ LD_PRELOAD=./test.so ./something Segmentation fault (core dumped)

But when I do

include

static void _construct() attribute((constructor)); static void _construct() { printf("hello\n"); }

$ g++-4.8 -Wall -fPIC -std=c++11 -shared -o test.so test.cpp $ LD_PRELOAD=./test.so ./something hello

On Mon, Mar 16, 2015 at 1:03 PM, yarf notifications@github.com wrote:

spoke too soon, though this is a different issue:

include <libcuckoo/cuckoohash_map.hh>

include <libcuckoo/city_hasher.hh>

typedef cuckoohash_map<int, int> Map; Map map; static void _construct() attribute((constructor));static void _construct() { printf ("{\n"); map[0] = 1010; printf ("}\n"); }

$ g++ -Wall -fPIC -std=c++11 -shared -o foo.so foo.cpp $ LD_PRELOAD=./foo.so someprocess { Segmentation fault (core dumped)

I'm suspecting this may be due to constructor ordering ... any idea how to resolve?

— Reply to this email directly or view it on GitHub https://github.com/efficient/libcuckoo/issues/6#issuecomment-81906838.

yarf commented 9 years ago

thanks Manu -- I see pain in my immediate future :)