Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build on OS X El Capitan #33

Open
shpsec-dennis opened this issue Apr 11, 2016 · 3 comments
Open

Cannot build on OS X El Capitan #33

shpsec-dennis opened this issue Apr 11, 2016 · 3 comments

Comments

@shpsec-dennis
Copy link

Hi,

I can't seem to build most of the targets on El Capitan.

$ cmake --version
cmake version 3.5.20160411-g9ac11

CMake suite maintained and supported by Kitware (kitware.com/cmake)
$ cmake .
-- JNI_INCLUDE_DIRS=/System/Library/Frameworks/JavaVM.framework/Headers;/System/Library/Frameworks/JavaVM.framework/Headers;/System/Library/Frameworks/JavaVM.framework/Headers
-- JNI_LIBRARIES=/System/Library/Frameworks/JavaVM.framework;/System/Library/Frameworks/JavaVM.framework
-- JAVA_INCLUDE_PATH=/System/Library/Frameworks/JavaVM.framework/Headers
-- JAVA_INCLUDE_PATH2=/System/Library/Frameworks/JavaVM.framework/Headers
-- LIBS: /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/bin/jar  incl: /System/Library/Frameworks/JavaVM.framework/Headers/../lib/tools.jar output_dir: /Users/username/code/perf-map-agent/out
-- Configuring done
CMake Warning (dev):
  Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
  --help-policy CMP0042" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

  MACOSX_RPATH is not specified for the following targets:

   perfmap

This warning is for project developers.  Use -Wno-dev to suppress it.

-- Generating done
-- Build files have been written to: /Users/username/code/perf-map-agent
$ make --debug
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Reading makefiles...
Updating goal targets....
 File `default_target' does not exist.
   File `all' does not exist.
     File `cmake_check_build_system' does not exist.
    Must remake target `cmake_check_build_system'.
    Successfully remade target file `cmake_check_build_system'.
  Must remake target `all'.
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Reading makefiles...
Updating goal targets....
 File `all' does not exist.
   File `CMakeFiles/attach-main.dir/all' does not exist.
  Must remake target `CMakeFiles/attach-main.dir/all'.
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Reading makefiles...
Updating goal targets....
 File `CMakeFiles/attach-main.dir/depend' does not exist.
Must remake target `CMakeFiles/attach-main.dir/depend'.
Successfully remade target file `CMakeFiles/attach-main.dir/depend'.
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Reading makefiles...
Updating goal targets....
 File `CMakeFiles/attach-main.dir/build' does not exist.
   File `attach-main' does not exist.
     File `CMakeFiles/attach-main' does not exist.
       File `out/attach-main.jar' does not exist.
           File `out/CMakeFiles/attach-main.dir/java_compiled_attach-main' does not exist.
          Must remake target `out/CMakeFiles/attach-main.dir/java_compiled_attach-main'.
[ 16%] Building Java objects for attach-main.jar
src/java/AttachOnce.java:25: error: package com.sun.tools.attach does not exist
import com.sun.tools.attach.VirtualMachine;
                           ^
src/java/AttachOnce.java:37: error: cannot find symbol
        VirtualMachine vm = VirtualMachine.attach(pid);
        ^
  symbol:   class VirtualMachine
  location: class AttachOnce
src/java/AttachOnce.java:37: error: cannot find symbol
        VirtualMachine vm = VirtualMachine.attach(pid);
                            ^
  symbol:   variable VirtualMachine
  location: class AttachOnce
src/java/AttachOnce.java:46: error: package com.sun.tools.attach does not exist
        } catch(com.sun.tools.attach.AgentInitializationException e) {
                                    ^
4 errors
make[2]: *** [out/CMakeFiles/attach-main.dir/java_compiled_attach-main] Error 1
make[1]: *** [CMakeFiles/attach-main.dir/all] Error 2
make: *** [all] Error 2
@jrudolph
Copy link
Member

tools.jar is probably not found at the place the build is expecting it. Can you try adopting CMakeLists.txt to use the path where it is available at your computer. You need to change this line:

set(CMAKE_JAVA_INCLUDE_PATH ${JAVA_INCLUDE_PATH}/../lib/tools.jar)

@shpsec-dennis
Copy link
Author

FWIW this makes it compile, not sure if it will work yet:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f5f7b28..f8f1785 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ project (perf-map-agent)
 # Binaries (agent libperfmap.so and attach-main.jar) will end up in ./out
 set(OUTDIR ${PROJECT_BINARY_DIR}/out)
 set(LIBRARY_OUTPUT_PATH ${OUTDIR})
+set(JAVA_INCLUDE_PATH /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/include)

 find_package(JNI)
 if (JNI_FOUND)
@@ -17,14 +18,19 @@ if (JNI_FOUND)
 endif()
 INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH})
 INCLUDE_DIRECTORIES(${JAVA_INCLUDE_PATH2})
+INCLUDE_DIRECTORIES(/usr/include)
+
+if(APPLE)
-    set(CMAKE_MACOSX_RPATH ON)
  +endif()
  
  add_library(perfmap SHARED src/c/perf-map-agent.c src/c/perf-map-file.c)
  
  find_package(Java REQUIRED)
  include(UseJava)

-set(CMAKE_JAVA_INCLUDE_PATH ${JAVA_INCLUDE_PATH}/../lib/tools.jar)
+set(CMAKE_JAVA_INCLUDE_PATH /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/tools.jar)
 set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${OUTDIR})

-#message(STATUS "LIBS: ${Java_JAR_EXECUTABLE} ${Java_INCLUDE_DIRS} incl: ${CMAKE_JAVA_INCLUDE_PATH} output_dir: ${CMAKE_JAVA_TARGET_OUTPUT_DIR}")
+message(STATUS "LIBS: ${Java_JAR_EXECUTABLE} ${Java_INCLUDE_DIRS} incl: ${CMAKE_JAVA_INCLUDE_PATH} output_dir: ${CMAKE_JAVA_TARGET_OUTPUT_DIR}")
 add_jar(attach-main src/java/AttachOnce.java ENTRY_POINT net/virtualvoid/perf/AttachOnce OUTPUT_DIR ${OUTDIR})
diff --git a/src/c/perf-map-file.c b/src/c/perf-map-file.c
index 838ccbc..8b2b253 100644
--- a/src/c/perf-map-file.c
+++ b/src/c/perf-map-file.c
@@ -20,12 +20,16 @@

 #include <sys/types.h>
 #include <stdio.h>
+#include <stdlib.h>

-#include <error.h>
+// #include <error.h>
 #include <errno.h>

 #include "perf-map-file.h"

+void error (int status, int errnum, const char *format, ...) {
+}
+
 FILE *perf_map_open(pid_t pid) {
     char filename[500];
     snprintf(filename, sizeof(filename), "/tmp/perf-%d.map", pid);```

@shpsec-dennis
Copy link
Author

shpsec-dennis commented Apr 15, 2016

Just saw the tools.jar comment. I received that error before and I set this manually and then I got a slew of different errors, I posted what I needed to do above, but I did adapt the CMake file, though in a hacky fashion: +set(CMAKE_JAVA_INCLUDE_PATH /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/lib/tools.jar)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants