{"action":"created","issue":{"url":"https://api.github.com/repos/node-ffi/node-ffi/issues/250","labels_url":"https://api.github.com/repos/node-ffi/node-ffi/issues/250/labels{/name}","comments_url":"https://api.github.com/repos/node-ffi/node-ffi/issues/250/comments","events_url":"https://api.github.com/repos/node-ffi/node-ffi/issues/250/events","html_url":"https://github.com/node-ffi/node-ffi/issues/250","id":109225380,"number":250,"title":"Dynamic Symbol Retrieval Error::Undefine symbol","user":{"login":"kimtn-bitmark","id":13616889,"avatar_url":"https://avatars.githubusercontent.com/u/13616889?v=3","gravatar_id":"","url":"https://api.github.com/users/kimtn-bitmark","html_url":"https://github.com/kimtn-bitmark","followers_url":"https://api.github.com/users/kimtn-bitmark/followers","following_url":"https://api.github.com/users/kimtn-bitmark/following{/other_user}","gists_url":"https://api.github.com/users/kimtn-bitmark/gists{/gist_id}","starred_url":"https://api.github.com/users/kimtn-bitmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimtn-bitmark/subscriptions","organizations_url":"https://api.github.com/users/kimtn-bitmark/orgs","repos_url":"https://api.github.com/users/kimtn-bitmark/repos","events_url":"https://api.github.com/users/kimtn-bitmark/events{/privacy}","received_events_url":"https://api.github.com/users/kimtn-bitmark/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-01T03:54:52Z","updated_at":"2015-10-08T08:16:44Z","closed_at":null,"body":"I'm trying to wrap a library and i got  `Dynamic Symbol Retrieval Error::Undefine symbol` error. Can you show me what is the mistake in my code?\r\n\r\nin `session.cpp`\r\n```\r\n#include <stdlib.h>\r\n#include <stdint.h>\r\n#include <stdio.h>\r\n#include \"libtorrent/entry.hpp\"\r\n#include \"libtorrent/bencode.hpp\"\r\n#include \"libtorrent/session.hpp\"\r\n\r\n#if defined(WIN32) || defined(_WIN32)\r\n#define EXPORT __declspec(dllexport)\r\n#else\r\n#define EXPORT\r\n#endif\r\n\r\nusing namespace libtorrent;\r\n\r\nEXPORT void listen_on(session& s, int min_, int max_)\r\n{\r\n    printf(\"Starting listener ........\\n\");\r\n    error_code ec;\r\n    s.listen_on(std::make_pair(min_, max_), ec);\r\n    if (ec) throw libtorrent_exception(ec);\r\n    printf(\"The listener has been listented on port %d........\\n\", min_);\r\n}\r\n\r\n```\r\n\r\nI was create c class to test mylib(and it's work well)\r\n```\r\n#include \"libtorrent/session.hpp\"\r\n#include \"../session.cpp\"\r\nint main()\r\n{\r\n    session s;\r\n\r\n    listen_on(s, 6881, 6889);\r\n\r\n    char a;\r\n    scanf(\"%c\\n\", &a);\r\n    return 0;\r\n}\r\n```\r\n\r\nMy node-wrapper class\r\n```\r\nvar ref = require(\"ref\");\r\nvar ffi = require(\"ffi\");\r\n\r\nvar path = require('path');\r\n\r\nvar LibSession = ffi.Library(path.resolve(__dirname, '../lib/session.so'), {\r\n  \"listen_on\": ['void', ['pointer', 'int', 'int']]\r\n});\r\n\r\nvar pointer = ref.alloc(ref.types.void)\r\n\r\n// test listen_on\r\nvar rtn = LibSession.listen_on(pointer, 6881, 6889);\r\n```"},"comment":{"url":"https://api.github.com/repos/node-ffi/node-ffi/issues/comments/146452740","html_url":"https://github.com/node-ffi/node-ffi/issues/250#issuecomment-146452740","issue_url":"https://api.github.com/repos/node-ffi/node-ffi/issues/250","id":146452740,"user":{"login":"kimtn-bitmark","id":13616889,"avatar_url":"https://avatars.githubusercontent.com/u/13616889?v=3","gravatar_id":"","url":"https://api.github.com/users/kimtn-bitmark","html_url":"https://github.com/kimtn-bitmark","followers_url":"https://api.github.com/users/kimtn-bitmark/followers","following_url":"https://api.github.com/users/kimtn-bitmark/following{/other_user}","gists_url":"https://api.github.com/users/kimtn-bitmark/gists{/gist_id}","starred_url":"https://api.github.com/users/kimtn-bitmark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kimtn-bitmark/subscriptions","organizations_url":"https://api.github.com/users/kimtn-bitmark/orgs","repos_url":"https://api.github.com/users/kimtn-bitmark/repos","events_url":"https://api.github.com/users/kimtn-bitmark/events{/privacy}","received_events_url":"https://api.github.com/users/kimtn-bitmark/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T08:16:44Z","updated_at":"2015-10-08T08:16:44Z","body":"Hi @TooTallNate \r\n\r\nMy environment are:\r\nUbuntu 14.0, node: 4.0\r\n\r\nThanks for your reply, my bug has been resolved\r\nBecause, i'm creating C code in `cpp` format, so i must change it to `c` format or add this line at begin of the `cpp` file `extern \"C\" {`"}}