简体   繁体   English

从源代码编译FreeImage。 #include FreeImage.h未找到

[英]Compiled FreeImage from source. #include FreeImage.h not found

I have compiled FreeImage 3.10.0 from source at /lib/FreeImage on Mac OS X 10.6. 我已经在Mac OS X 10.6的/ lib / FreeImage上从源代码编译了FreeImage 3.10.0。

I can see that after compilation these files were copied: 我可以看到编译后这些文件被复制了:

/usr/local/lib/libfreeimage-3.10.0.dylib
/usr/local/lib/libfreeimage.a
/usr/local/include/FreeImage.h

CMake cannot find FreeImage, but I cannot even do CMake找不到FreeImage,但我什至找不到

#include <FreeImage.h>  // not found

I am assuming I need to add FreeImage.h to the Mac OS X environment path, except I don't know which path is the right one as there are a few different files which store environment path variables. 我假设我需要将FreeImage.h添加到Mac OS X环境路径中,除非我不知道哪个路径是正确的路径,因为有几个存储环境路径变量的文件不同。

What do I need to do to get FreeImage header to be found by my C++ app or CMake? 我该怎么做才能使FreeImage标头可以被我的C ++应用程序或CMake找到?

Here is the first part of my Makefile.osx is this helps: 这是我的Makefile.osx的第一部分,它会有所帮助:

# -*- Makefile -*-
# Mac OSX makefile for FreeImage

# This file can be generated by ./gensrclist.sh
include Makefile.srcs

# General configuration variables:
CC_PPC = gcc-4.0
CC_I386 = gcc-4.0
CPP_PPC = g++-4.0
CPP_I386 = g++-4.0
COMPILERFLAGS = -Os -fexceptions -fvisibility=hidden
COMPILERFLAGS_PPC = -arch ppc
COMPILERFLAGS_I386 = -arch i386
COMPILERPPFLAGS = -Wno-ctor-dtor-privacy
INCLUDE += 
INCLUDE_PPC = -isysroot /Developer/SDKs/MacOSX10.6.sdk
INCLUDE_I386 = -isysroot /Developer/SDKs/MacOSX10.6.sdk
CFLAGS_PPC = $(COMPILERFLAGS) $(COMPILERFLAGS_PPC) $(INCLUDE) $(INCLUDE_PPC)
CFLAGS_I386 = $(COMPILERFLAGS) $(COMPILERFLAGS_I386) $(INCLUDE) $(INCLUDE_I386)
CPPFLAGS_PPC = $(COMPILERPPFLAGS) $(CFLAGS_PPC)
CPPFLAGS_I386 = $(COMPILERPPFLAGS) $(CFLAGS_I386)
LIBRARIES_PPC = -Wl,-syslibroot /Developer/SDKs/MacOSX10.6.sdk
LIBRARIES_I386 = -Wl,-syslibroot /Developer/SDKs/MacOSX10.6.sdk
LIBTOOL = libtool
LIPO = lipo

Update: I added these lines into my Makefile as per Nicholas' instructions, then rebuilt but this didn't work: 更新:按照尼古拉斯的指示,将以下几行添加到我的Makefile中,然后重新构建,但这不起作用:

CFLAGS = -I/usr/local/include
LDFLAGS = -L/usr/local/lib

编译时,必须将-I / usr / local / include添加到CFLAGS,将-L / usr / local / lib添加到LDFLAGS。

Compiling with gcc -c file.c -o file.o -I /usr/local/include should compile your file that refers FreeImage.h. 使用gcc -c file.c -o file.o -I / usr / local / include进行编译应编译引用FreeImage.h的文件。

However, when using isysroot everything becomes relative to the system root (ie your refrence to /usr/local/include is in fact isysroot /usr/local/include). 但是,使用isysroot时,所有内容都相对于系统根目录(即,您对/ usr / local / include的引用实际上是isysroot / usr / local / include)。 "gcc -v" will show everything that goes on, making things easy: “ gcc -v”将显示所有发生的事情,使事情变得容易:

tmp diciu$ gcc -v -isysroot /Developer/SDKs/MacOSX10.6.sdk test.c
[..]
ignoring nonexistent directory "/Developer/SDKs/MacOSX10.6.sdk/usr/local/include"

The ' INCLUDE += ' line looks like the one to attack: ' INCLUDE += '行看起来像是要攻击的行:

INCLUDE += -I/usr/local/include

If the library is missing too, then you will need to find another line to add ' -L/usr/include/lib ' to. 如果该库也丢失了,那么您将需要寻找另一行来添加' -L/usr/include/lib '。

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

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