[英]C++ Why can't the linker see my files?
Building a native module for Node.js under Cygwin / Windows:在 Cygwin / Windows 下为 Node.js 构建本机模块:
I have a monkey.cc file with this:我有一个monkey.cc文件:
#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/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
. monkeyFoo
在monkey.h
中定义,该目录位于名为monkey
的目录中。 I am running the above command from the directory containing monkey
directory and monkey.cc
file.我正在从包含
monkey
目录和monkey.cc
文件的目录运行上述命令。
EDIT:编辑:
wscript, which is the python script that node-waf runs looks like this: wscript,即 node-waf 运行的 python 脚本,如下所示:
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.那是 linker 错误,而不是编译器错误。 Do you have a definition for the function?
您对 function 有定义吗? (Not just a declaration.) And are you sure it's being linked in?
(不仅仅是一个声明。)你确定它被链接了吗?
Add monkey.lib='crypto'
in the wscript.在 wscript 中添加
monkey.lib='crypto'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.