繁体   English   中英

与GHC链接

[英]Linking with GHC

我正在关注这个简短的教程

并尝试使用GHC(Glasgow Haskell编译器,版本7.10.1)通过以下命令编译Webots应用程序(用C编写):

ghc --make -no-hs-main -optc-O 
-I"/Applications/Webots/include/controller/c/" 
-L"/Applications/Webots/lib/" 
-outputdir build/release/ 
advanced_genetic_algorithm_supervisor.c 
Safe 
-o advanced_genetic_algorithm_supervisor

并在链接阶段得到以下错误:

Linking advanced_genetic_algorithm_supervisor ...
Undefined symbols for architecture x86_64:
  "_wb_display_draw_text", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_display_get_height", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_display_get_width", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_emitter_send", referenced from:
      _evaluate_genotype in advanced_genetic_algorithm_supervisor.o
  "_wb_receiver_enable", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_receiver_get_data", referenced from:
      _check_for_slaves_data in advanced_genetic_algorithm_supervisor.o
  "_wb_receiver_get_queue_length", referenced from:
      _check_for_slaves_data in advanced_genetic_algorithm_supervisor.o
  "_wb_receiver_next_packet", referenced from:
      _check_for_slaves_data in advanced_genetic_algorithm_supervisor.o
  "_wb_robot_cleanup", referenced from:
      _run_optimization in advanced_genetic_algorithm_supervisor.o
  "_wb_robot_get_basic_time_step", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_robot_get_device", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_robot_init", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_robot_step", referenced from:
      _run_seconds in advanced_genetic_algorithm_supervisor.o
      _evaluate_genotype in advanced_genetic_algorithm_supervisor.o
  "_wb_supervisor_field_get_sf_rotation", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_supervisor_field_get_sf_vec3f", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_supervisor_field_set_sf_rotation", referenced from:
      _evaluate_genotype in advanced_genetic_algorithm_supervisor.o
  "_wb_supervisor_field_set_sf_vec3f", referenced from:
      _evaluate_genotype in advanced_genetic_algorithm_supervisor.o
  "_wb_supervisor_node_get_field", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
  "_wb_supervisor_node_get_from_def", referenced from:
      _main in advanced_genetic_algorithm_supervisor.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我相信这意味着编译器无法找到函数(“符号”),尽管它设法通过编译过程来解析使用-I路径在程序中指定的所有包含项

这意味着链接器找不到那些函数/符号,因为您没有告诉它要与Webots库链接。

假设库文件名为/Applications/Webots/lib/libsomething.dylib (或libsomething.a ),则需要添加-lsomething

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM