Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference when building a sharedlib #6

Closed
yarf opened this issue Mar 15, 2015 · 7 comments
Closed

undefined reference when building a sharedlib #6

yarf opened this issue Mar 15, 2015 · 7 comments

Comments

@yarf
Copy link

yarf commented Mar 15, 2015

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
Copy link
Member

apc999 commented Mar 15, 2015

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 [email protected] 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
#6.

Computer Science Department
Carnegie Mellon University

@yarf
Copy link
Author

yarf commented Mar 15, 2015

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
Copy link
Contributor

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 [email protected] 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 [email protected]
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 [email protected] 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
#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
#6 (comment).

@yarf
Copy link
Author

yarf commented Mar 16, 2015

That appears to have done the trick -- thanks!

@yarf
Copy link
Author

yarf commented Mar 16, 2015

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
Copy link
Contributor

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 <stdio.h>

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 [email protected] 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
#6 (comment).

@yarf
Copy link
Author

yarf commented Mar 16, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants