have run into a problem lately where I was looking for a particular header file. I couldn’t find it anywhere until I stumbled across it’s source in a google search which lead me to this site:
http://opensource.apple.com/release/mac-os-x-1068/
My question: Are these projects that are supposed to be downloaded separately, one at a time, to be used on OSX, or are they supposed to be already included with some developer package of OSX? I am a new OSX user, and all I know presently is that I have xcode on the box, but seem to be missing some libs that my code (given to me) is looking for.
Here is what my cmake file looks like:
project(myproject)
cmake_minimum_required(VERSION 2.8)
SET(CMAKE_BUILD_TYPE debug)
SET(CMAKE_C_FLAGS_DEBUG "-g -fPIC -O0 -pipe -std=c99")
SET(CMAKE_VERBOSE_MAKEFILE TRUE)
file(GLOB HEADER_LIST ./include/*.h)
include_directories(./include)
add_executable(${PROJECT_NAME} ${SRC_LIST} ${HEADER_LIST})
target_link_libraries(${PROJECT_NAME} -lpcap)
and my source file has
#include <net/bpf.h>
#include <pcap.h>
however, I am getting some errors with trying to use the structures that are supposed to be in pcap not being defined. Should I pull pcap separately from this apple open source lib, or as a part of a bigger package?
Thanks
EDIT: Your problem is that you’re relying on a private, internal data structure.
pcap-int.his not provided because it is not part of the public API.Most library headers (including pcap) are available in
/usr/include, though typically you link them from the developer SDKs so that you can control the specific version you’re building against. To include and link with the correct headers and libraries using cmake, you generally use theCMAKE_OSX_SYSROOTvariable. You control the deployment target withCMAKE_OSX_DEPLOYMENT_TARGET. For example, here is an old one of mine:The latest versions of Xcode are no longer in
/Developer, so you would need to point into/Applications/Xcode.app. You can get the correct path using:Not everything on opensource.apple.com is available in the SDKs directly. Some things are private. You could install them from opensource.apple.com, though I’ve often found that they won’t correctly build that way (you often wind up having to install a lot of other packages from Apple and it gets to be a headache). If you need something like that, it’s often much easier to just install the “normal” version and statically link it into your program.
But pcap should work fine. What problem are you actually seeing?