vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
533 stars 89 forks source link

Linking error on macOS with clang: `Undefined symbols for architecture x86_64: "_add_history"` etc. #437

Closed barracuda156 closed 3 months ago

barracuda156 commented 3 months ago
      /usr/bin/clang++ -DHAVE_CONFIG_H -D_FILE_OFFSET_BIS=64 -DUSEGC -DLSPCPP_USEGC  -D_THREAD_SAFE -pthread -DFFTWPP_SINGLE_THREAD -Wall -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -I. -I/opt/local/include/gc -I/usr/include/gc       -pipe -Os -std=c++14 -stdlib=libc++ -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch x86_64 -pipe -Os -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch x86_64 -ILspCpp/include -o asy camperror.o path.o drawpath.o drawlabel.o picture.o psfile.o texfile.o util.o settings.o guide.o flatguide.o knot.o drawfill.o path3.o drawpath3.o drawsurface.o beziercurve.o bezierpatch.o pen.o pipestream.o types.o builtin.o gsl.o runtime.o runbacktrace.o runpicture.o runlabel.o runhistory.o runarray.o runfile.o runsystem.o runpair.o runtriple.o runpath.o runpath3d.o runstring.o runmath.o env.o genv.o stm.o dec.o errormsg.o callable.o name.o symbol.o entry.o exp.o newexp.o stack.o camp.tab.o lex.yy.o access.o virtualfieldaccess.o absyn.o record.o interact.o fileio.o fftw++asy.o parallel.o simpson.o coder.o coenv.o impdatum.o locate.o parser.o program.o application.o varinit.o fundec.o refaccess.o envcompleter.o process.o constructor.o array.o Delaunay.o predicates.o PRCbitStream.o oPRCFile.o PRCdouble.o writePRC.o glrender.o tr.o shaders.o jsfile.o v3dfile.o tinyexr.o EXRFiles.o GLTextures.o lspserv.o symbolmaps.o main.o revision.o -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -arch x86_64                 -LLspCpp -LLspCpp/third_party/uri/src  glew.o  -lcurl -lsigsegv -lz -L/opt/local/lib -lgc -lgsl -lgslcblas -framework GLUT -framework OpenGL -framework Cocoa    ; \
    fi
  Undefined symbols for architecture x86_64:
    "_add_history", referenced from:
        run::gen_runhistory3(vm::stack*) in runhistory.o
        interact::addToHistory(std::__1::basic_string<char, std::__1::char_traits<char>, gc_allocator_ignore_off_page<char> >) in interact.o
    "_cur_term", referenced from:
        settings::getScroll() in settings.o
    "_fftw_destroy_plan", referenced from:
        fftwpp::fftw::~fftw() in runarray.o
    "_fftw_execute_dft", referenced from:
        fftwpp::fftw::Execute(std::__1::complex<double>*, std::__1::complex<double>*, bool) in runarray.o
        fftwpp::fft2d::Execute(std::__1::complex<double>*, std::__1::complex<double>*, bool) in runarray.o
    "_fftw_export_wisdom_to_string", referenced from:
        fftwpp::saveWisdom() in fftw++asy.o
    "_fftw_free", referenced from:
        fftwpp::saveWisdom() in fftw++asy.o
    "_fftw_import_wisdom_from_string", referenced from:
        fftwpp::loadWisdom() in fftw++asy.o
    "_fftw_plan_dft_1d", referenced from:
        fftwpp::fft1d::Plan(std::__1::complex<double>*, std::__1::complex<double>*) in runarray.o
    "_fftw_plan_dft_2d", referenced from:
        fftwpp::fft2d::Plan(std::__1::complex<double>*, std::__1::complex<double>*) in runarray.o
    "_fftw_plan_dft_3d", referenced from:
        fftwpp::fft3d::Plan(std::__1::complex<double>*, std::__1::complex<double>*) in runarray.o
    "_history_get", referenced from:
        get_history(long long) in runhistory.o
    "_history_get_history_state", referenced from:
        store_history(_hist_state*) in runhistory.o
    "_history_length", referenced from:
        get_history(long long) in runhistory.o
        interact::getLastHistoryLine() in interact.o
        interact::setLastHistoryLine(std::__1::basic_string<char, std::__1::char_traits<char>, gc_allocator_ignore_off_page<char> >) in interact.o
        interact::deleteLastLine() in interact.o
    "_history_list", referenced from:
        interact::getLastHistoryLine() in interact.o
    "_history_set_history_state", referenced from:
        run::cleanup() in runhistory.o
        run::gen_runhistory0(vm::stack*) in runhistory.o
        run::gen_runhistory2(vm::stack*) in runhistory.o
        run::gen_runhistory3(vm::stack*) in runhistory.o
    "_read_history", referenced from:
        run::gen_runhistory0(vm::stack*) in runhistory.o
        run::gen_runhistory2(vm::stack*) in runhistory.o
        run::gen_runhistory3(vm::stack*) in runhistory.o
        interact::init_interactive() in interact.o
    "_readline", referenced from:
        run::gen_runhistory2(vm::stack*) in runhistory.o
        interact::pre_readline() in interact.o
       (maybe you meant: _PRETRANSLATED_SYMBOL_readline, interact::pre_readline() , interact::init_readline(bool) )
    "_remove_history", referenced from:
        interact::setLastHistoryLine(std::__1::basic_string<char, std::__1::char_traits<char>, gc_allocator_ignore_off_page<char> >) in interact.o
        interact::deleteLastLine() in interact.o
    "_rl_bind_key", referenced from:
        interact::init_readline(bool) in interact.o
        interact::init_interactive() in interact.o
    "_rl_complete", referenced from:
        interact::init_readline(bool) in interact.o
        interact::init_interactive() in interact.o
    "_rl_completion_append_character", referenced from:
        interact::init_completion() in interact.o
        interact::init_interactive() in interact.o
    "_rl_completion_entry_function", referenced from:
        interact::init_completion() in interact.o
        interact::init_interactive() in interact.o
    "_rl_insert", referenced from:
        interact::init_readline(bool) in interact.o
        interact::init_interactive() in interact.o
    "_setupterm", referenced from:
        settings::getScroll() in settings.o
    "_stifle_history", referenced from:
        run::cleanup() in runhistory.o
        interact::cleanup_interactive() in interact.o
    "_unstifle_history", referenced from:
        run::cleanup() in runhistory.o
    "_write_history", referenced from:
        run::cleanup() in runhistory.o
        interact::cleanup_interactive() in interact.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make: *** [asy] Error 1
johncbowman commented 3 months ago

You need to link with -lreadline and -lncurses. The root of the problem is that Asymptote assumes you have a working pkg-config. We're about to drop that requirement; that should help avoid such issues.

barracuda156 commented 3 months ago

@johncbowman Thank you, let me try add a dependency on pkgconfig, that could explain why CI failed but locally everything built fine.

barracuda156 commented 3 months ago

@johncbowman That worked, thanks again. Closing as resolved.

johncbowman commented 3 months ago

With commit 459e6267d41a0524c92d4ec1db4d5a0a67fc1080, pkg-config should no longer be required (although it may still be helpful in automatically determining the correct configure flags to enable certain features).

barracuda156 commented 3 months ago

@johncbowman Thank you! (I guess we can still keep it in the portfile, it is not a problematic dependency to have.)