c++ - Compiling libzip on Mac: Undefined symbols for architecture x86_64 -


i've been learning c++ , have decided try create simple file reader using libzip on archive files (e.g. word).

i’ve installed libzip on macbook using brew seem keep on getting following issue whenever try compile program uses libzip:

undefined symbols architecture x86_64:   "_zip_fopen", referenced from:       _main in main-918bfa.o   "_zip_open", referenced from:       _main in main-918bfa.o ld: symbol(s) not found architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) make: *** [a.exe] error 1 

the command use compile:

g++ -g main.cpp -std=c++11 -i/usr/local/cellar/libzip/0.11.2/include -i/usr/local/cellar/libzip/0.11.2/lib/libzip/include -l/usr/local/cellar/libzip/0.11.2/lib -o ../a.exe 

main.cpp:

 #include <iostream>  #include <fstream>  #include <zip.h>  #include <zlib.h>   using namespace std;  int numargs = 2;   int main(int argc, char** argv){      // parse command line arguments      if(argc != numargs){          std::cout << "incorrect number of arguments provided.\n";          std::cout << "command line syntax: filereader.exe inputfile" << endl;          exit(0);      }       // try out libzip functionality      std::string inputdocument(argv[1]);      int err = 0;      zip* z = zip_open(inputdocument.c_str(), 0, &err);      if(z == null) {          printf("could not read docx file. error code: %d", err);          exit(-1);      }      zip_file* contenttypes = zip_fopen(z, "[content_types].xml", zip_fl_unchanged);      exit(0);  } 

doesn't including libzip library in compilation command. try adding -lzip g++ command


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -