Problem compiling from source in OSX 10.8.4

Help
2013-08-12
2013-08-13
  • Chetan Sachdev
    Chetan Sachdev
    2013-08-12

    I am trying to compile highlight from the source files. To do this, I followed these steps:
    1. Downloaded lua5.1 from http://www.lua.org/versions.html#5.1, followed the installation steps and "lua -v" shows
    Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
    2. Downloaded Boost library from http://www.boost.org/, placed the folder in /usr/local/boost_1_54_0/ and after a couple of googling, created a symbolic link as sudo ln -s /usr/local/boost_1_54_0/boost src/include/boost. This resolved the linking problem to Boost library

    Now, I am getting a couple of different errors:

    1. Package lua5.1 was not found in the pkg-config search path.
      Perhaps you should add the directory containing `lua5.1.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'lua5.1' found
      ======
    2. c++ -Wall -O2 -DNDEBUG -c -I ./include/ ./core/astyle/ASFormatter.cpp
      ./core/astyle/ASFormatter.cpp:4961:10: warning: implicit conversion of NULL constant to
      'bool' [-Wnull-conversion]
      return NULL;
      false
      ./core/astyle/ASFormatter.cpp:4964:10: warning: implicit conversion of NULL constant to
      'bool' [-Wnull-conversion]
      return NULL;
      false
      2 warnings generated.
      ======
    3. c++ -ldl -o highlight arg_parser.o cmdlineoptions.o main.o help.o -L. -lhighlight
      Undefined symbols for architecture x86_64:
      "_luaL_loadbuffer", referenced from:
      Diluculum::LuaState::doStringOrFile(bool, std::string const&) in libhighlight.a(LuaState.o)
      "_luaL_loadfile", referenced from:
      Diluculum::LuaState::doStringOrFile(bool, std::string const&) in libhighlight.a(LuaState.o)
      "_luaL_newstate", referenced from:
      Diluculum::LuaState::LuaState(bool) in libhighlight.a(LuaState.o)
      "_luaL_openlibs", referenced from:
      Diluculum::LuaState::LuaState(bool) in libhighlight.a(LuaState.o)
      Diluculum::LuaState::LuaState(lua_State, bool) in libhighlight.a(LuaState.o)
      Diluculum::LuaState::LuaState(lua_State
      , bool) in libhighlight.a(LuaState.o)
      "_lua_close", referenced from:
      Diluculum::LuaState::~LuaState() in libhighlight.a(LuaState.o)
      Diluculum::LuaState::~LuaState() in libhighlight.a(LuaState.o)
      Diluculum::LuaState::~LuaState() in libhighlight.a(LuaState.o)
      "_lua_createtable", referenced from:
      Diluculum::PushLuaValue(lua_State, Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_dump", referenced from:
      Diluculum::ToLuaValue(lua_State
      , int) in libhighlight.a(LuaUtils.o)
      "_lua_getfield", referenced from:
      highlight::SyntaxReader::luaAddKeyword(lua_State) in libhighlight.a(syntaxreader.o)
      "_lua_gettable", referenced from:
      Diluculum::LuaVariable::pushLastTable() in libhighlight.a(LuaVariable.o)
      Diluculum::LuaVariable::pushTheReferencedValue() const in libhighlight.a(LuaVariable.o)
      "_lua_gettop", referenced from:
      Diluculum::LuaState::doStringOrFile(bool, std::string const&) in libhighlight.a(LuaState.o)
      highlight::SyntaxReader::luaAddKeyword(lua_State
      ) in libhighlight.a(syntaxreader.o)
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      Diluculum::Impl::CallFunctionOnTop(lua_State
      , std::vector<Diluculum::LuaValue, std::allocator<Diluculum::LuaValue=""> > const&) in libhighlight.a(InternalUtils.o)
      "_lua_iscfunction", referenced from:
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      "_lua_isstring", referenced from:
      Diluculum::Impl::ThrowOnLuaError(lua_State
      , int) in libhighlight.a(InternalUtils.o)
      "_lua_load", referenced from:
      Diluculum::PushLuaValue(lua_State, Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_newuserdata", referenced from:
      highlight::SyntaxReader::load(std::string const&, std::string const&, highlight::OutputType, bool) in libhighlight.a(syntaxreader.o)
      Diluculum::PushLuaValue(lua_State
      , Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_next", referenced from:
      Diluculum::LuaState::globals() in libhighlight.a(LuaState.o)
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      "_lua_objlen", referenced from:
      Diluculum::ToLuaValue(lua_State
      , int) in libhighlight.a(LuaUtils.o)
      "_lua_pcall", referenced from:
      Diluculum::LuaState::doStringOrFile(bool, std::string const&) in libhighlight.a(LuaState.o)
      Diluculum::Impl::CallFunctionOnTop(lua_State, std::vector<Diluculum::LuaValue, std::allocator<Diluculum::LuaValue=""> > const&) in libhighlight.a(InternalUtils.o)
      "_lua_pushboolean", referenced from:
      highlight::SyntaxReader::luaAddKeyword(lua_State
      ) in libhighlight.a(syntaxreader.o)
      Diluculum::PushLuaValue(lua_State, Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_pushcclosure", referenced from:
      highlight::SyntaxReader::load(std::string const&, std::string const&, highlight::OutputType, bool) in libhighlight.a(syntaxreader.o)
      Diluculum::PushLuaValue(lua_State
      , Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_pushlstring", referenced from:
      Diluculum::PushLuaValue(lua_State, Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_pushnil", referenced from:
      Diluculum::LuaState::globals() in libhighlight.a(LuaState.o)
      Diluculum::ToLuaValue(lua_State
      , int) in libhighlight.a(LuaUtils.o)
      Diluculum::PushLuaValue(lua_State, Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_pushnumber", referenced from:
      Diluculum::PushLuaValue(lua_State
      , Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_pushstring", referenced from:
      Diluculum::LuaVariable::pushLastTable() in libhighlight.a(LuaVariable.o)
      "_lua_pushvalue", referenced from:
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      "_lua_remove", referenced from:
      Diluculum::LuaVariable::pushLastTable() in libhighlight.a(LuaVariable.o)
      Diluculum::LuaVariable::pushTheReferencedValue() const in libhighlight.a(LuaVariable.o)
      "_lua_setfield", referenced from:
      highlight::SyntaxReader::load(std::string const&, std::string const&, highlight::OutputType, bool) in libhighlight.a(syntaxreader.o)
      "_lua_settable", referenced from:
      Diluculum::LuaVariable::operator=(Diluculum::LuaValue const&) in libhighlight.a(LuaVariable.o)
      Diluculum::PushLuaValue(lua_State
      , Diluculum::LuaValue const&) in libhighlight.a(LuaUtils.o)
      "_lua_settop", referenced from:
      Diluculum::LuaState::doStringOrFile(bool, std::string const&) in libhighlight.a(LuaState.o)
      Diluculum::LuaState::globals() in libhighlight.a(LuaState.o)
      Diluculum::LuaVariable::operator=(Diluculum::LuaValue const&) in libhighlight.a(LuaVariable.o)
      Diluculum::LuaVariable::value() const in libhighlight.a(LuaVariable.o)
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      Diluculum::Impl::CallFunctionOnTop(lua_State
      , std::vector<Diluculum::LuaValue, std::allocator<Diluculum::LuaValue=""> > const&) in libhighlight.a(InternalUtils.o)
      Diluculum::Impl::ThrowOnLuaError(lua_State, int) in libhighlight.a(InternalUtils.o)
      ...
      "_lua_toboolean", referenced from:
      Diluculum::ToLuaValue(lua_State
      , int) in libhighlight.a(LuaUtils.o)
      "_lua_tocfunction", referenced from:
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      "_lua_tolstring", referenced from:
      Diluculum::LuaState::globals() in libhighlight.a(LuaState.o)
      highlight::SyntaxReader::luaAddKeyword(lua_State
      ) in libhighlight.a(syntaxreader.o)
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      Diluculum::Impl::ThrowOnLuaError(lua_State
      , int) in libhighlight.a(InternalUtils.o)
      "_lua_tonumber", referenced from:
      highlight::SyntaxReader::luaAddKeyword(lua_State) in libhighlight.a(syntaxreader.o)
      Diluculum::ToLuaValue(lua_State
      , int) in libhighlight.a(LuaUtils.o)
      "_lua_touserdata", referenced from:
      highlight::SyntaxReader::luaAddKeyword(lua_State) in libhighlight.a(syntaxreader.o)
      Diluculum::ToLuaValue(lua_State
      , int) in libhighlight.a(LuaUtils.o)
      "_lua_type", referenced from:
      Diluculum::LuaState::globals() in libhighlight.a(LuaState.o)
      Diluculum::LuaVariable::pushLastTable() in libhighlight.a(LuaVariable.o)
      Diluculum::LuaVariable::pushTheReferencedValue() const in libhighlight.a(LuaVariable.o)
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      Diluculum::Impl::CallFunctionOnTop(lua_State
      , std::vector<Diluculum::LuaValue, std::allocator<Diluculum::LuaValue=""> > const&) in libhighlight.a(InternalUtils.o)
      "_lua_typename", referenced from:
      Diluculum::LuaVariable::pushLastTable() in libhighlight.a(LuaVariable.o)
      Diluculum::ToLuaValue(lua_State, int) in libhighlight.a(LuaUtils.o)
      Diluculum::Impl::CallFunctionOnTop(lua_State
      , std::vector<Diluculum::LuaValue, std::allocator<Diluculum::LuaValue=""> > const&) in libhighlight.a(InternalUtils.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[1]: [cli] Error 1
      make:
      [all] Error 2
      ======

    Is there a wiki with step by step instructions, on how to configure it. Could you please help me to resolve this. I am using highlight-3.14.

    Thx

     
  • André Simon
    André Simon
    2013-08-12

    Hi,

    I have not much OS X experience, but:
    your Lua setup is not integrated in your pkg-config database.

    Edit src/makefile and replace the pkg-config calls like this:

    LUA_CFLAGS=$(shell pkg-config --cflags lua)
    ->
    LUA_CFLAGS=
    
    LUA_LIBS=$(shell pkg-config --libs lua)
    ->
    LUA_LIBS=-llua -lm
    

    Then run make again.
    Make sure that your Lua lib can be found by the linker (i.e. run ldconfig)

    hth
    André

     
  • Chetan Sachdev
    Chetan Sachdev
    2013-08-13

    Thanks for your reply André. I updated the make file of highlight, as you suggested. It solved my first error. Now, a part of make file looks like below:

    #If Lua 5.2 is not default on your system yet you have to omit 5.1:
    LUA_CFLAGS=
    #$(shell pkg-config --cflags lua5.1)
    # default lua lib
    LUA_LIBS=
    #$(shell pkg-config --libs lua5.1)
    

    I haven't programmed in lua at all. How do I run ldconfig? I did a locate command in terminal, but there is no ldconfig executable available. I tried to search and found that ldconfig should be available in /sbin/ldconfig, but this is not available. Do I need to download some library for lua?

     
  • André Simon
    André Simon
    2013-08-13

    LUA_LIBS cannot be empty - it normally contains "-llua -lm". When you compiled lua (the interpreter) you can see which libs were used in the lua makefile.

    ldconfig is not needed for lua. I mentioned it in case the linker would not find the lua library, then running ldconfig would update the lib cache. Possibly ldconfig is a part of Darwin development tools.

    Unfortunately I have no access to a Mac so I cannot give concrete hints.

     
  • Chetan Sachdev
    Chetan Sachdev
    2013-08-13

    Thanks. Installation from homebrew worked!! :)
    Will explore this issue later, when time allows.