开发者

C++ Why can't the linker see my files?

Building a native module for Node.js under Cygwin / Windows:

I have a monkey.cc file with this:

#include <monkey/monkey.h>

running

node-waf configure build

I get the following

'configure' finished successfully (0.351s)
Waf: Entering directory `/usr/src/build'
[2/2] cxx_link: build/default/monkey_1.o -> build/default/monkey.node build/default/libmonkey.dll.a
Creating library file: default开发者_JAVA技巧/libmonkey.dll.a

then the following error:

default/monkey_1.o:/usr/src/build/../monkey.cc:144: undefined reference to `_monkeyFoo'

monkeyFoo is defined in monkey.h which is in a directory named monkey. I am running the above command from the directory containing monkey directory and monkey.cc file.

EDIT:

wscript, which is the python script that node-waf runs looks like this:

import os

srcdir = '.'
blddir = './build'
VERSION = '0.0.2'

def set_options(opt):
  opt.tool_options('compiler_cxx')

def configure(conf):
  conf.check_tool('compiler_cxx')
  conf.check_tool('node_addon')

def build(bld):
  monkey = bld.new_task_gen('cxx', 'shlib', 'node_addon')
  monkey.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall", "-L/usr/lib", "-lssl"]
  monkey.chmod = 0755
  monkey.target = 'monkey'
  monkey.source = 'monkey.cc'

What am I missing???


That's a linker error, not a compiler error. Do you have a definition for the function? (Not just a declaration.) And are you sure it's being linked in?


Add monkey.lib='crypto' in the wscript.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜