如何在制作PCA-SIFT代码时指定pgm库的include和lib路径

时间:2016-02-27 07:50:10

标签: linux makefile include-path pkg-config

我正在尝试在此网页中制作PCA-SIFT代码(pcasift-0.91nd.tar.gz):http://www.cs.cmu.edu/~yke/pcasift/。运行./configure后即可,make命令报告C编译器无法找到头文件pgm.h:

  

image.cc:18:22:致命错误:pgm.h:没有这样的文件或目录         #包括                         ^编译终止。

互联网上有一个网页讨论了这个问题:http://ubuntuforums.org/showthread.php?t=1918422。最后提出了一个解决方案:

  

显然,头文件位于/usr/include/pgm-5.1目录中    - 编译时将其放入include目录的首选方法是使用pkgconfig。你需要添加类似的东西   编译结束时pkg-config --cflags openpgm-5.1   命令获取正确的标题并将pkg-config --libs openpgm-5.1添加到链接命令。

,但我无法理解。具体来说,“编译命令末尾添加pkg-config --cflags openpgm-5.1”是什么意思?我应该怎么做,从字面上添加pkg-config --cflags openpgm-5.1或者此命令在终端中返回的结果?并添加到什么文件? Makefile由./configure生成。我应该添加到Makefile还是./configure?我已经成功安装了libpgm-dev,它们确实在/usr/include/pgm-5.1中。命令pkg-config --cflags openpgm-5.1返回-I/usr/include/pgm-5.1 -I/usr/lib/x86_64-linux-gnu/pgm-5.1/include,命令pkg-config --libs openpgm-5.1返回-lpgm -lpthread -lm

由于该线程已经关闭,我不得不在这里问一下。希望熟悉Linux编译过程的人可以帮助我解决这个问题。非常感谢。

1 个答案:

答案 0 :(得分:1)

我自己解决了这个问题。

原始问题中提到的ubuntuforums.org网页中的所有内容都是错误的;这就是我遇到这么多问题的原因。

错误1:使用func getData() { let myURLString = "http://meetup.x10host.com/api/get_event.php?radius=15" let myURL = NSURL(string: myURLString)! var myCardsArray = [Card]() let mySession = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration()) let myDataTask = mySession.dataTaskWithURL(myURL) { (data, response, error) in guard error == nil else { let alertController = UIAlertController(title: "No Connection", message: "Can't connect to database, perhaps turn on your WiFi?", preferredStyle: UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default,handler: nil)) self.presentViewController(alertController, animated: true, completion: nil) return } do { let jsonData = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.AllowFragments) for someCard in jsonData as! NSArray{ let card = Mapper<Card>().map(someCard) myCardsArray.append(card!) self.nameArray.append(card!.titlee!) self.textArray.append(card!.text!) self.userArray.append(card!.attending!) self.latArray.append(card!.latitude!) self.longArray.append(card!.longitude!) self.timeArray.append(card!.time!) self.locTextArray.append(card!.locationText!) dispatch_async(dispatch_get_main_queue()) { self.tableView.reloadData() } } } catch { print("There was an error") } } myDataTask.resume() print(nameArray) } 安装libpgm-dev是错误的。 我们应该下载Netpbm,并在解压缩后运行以下命令:

sudo apt-get install libpgm-dev

然后在Ubuntu上安装Netpbm。

错误2. ./configure //type none on prompt if you don't have JPEG, TIFF, etc. libraries make sudo make package pkgdir=netpbmpkg sudo ./installnetpbm sudo rm -f -r /netpbmpkg/ 返回的包含路径错误

默认情况下,包含路径为pkg-config --cflags,lib路径为/usr/local/netpbm/include

错误3. /usr/local/netpbm/lib返回的关联选项-lpgm错误

正确的关联选项应为pkg-config --libs

按照正确的方法,我可以在Netbeans中成功编译项目(忘记命令行制作)。