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

Building test program in OSX #4

Closed
kronocharia opened this issue Feb 13, 2015 · 8 comments
Closed

Building test program in OSX #4

kronocharia opened this issue Feb 13, 2015 · 8 comments

Comments

@kronocharia
Copy link

Has anyone had any success building the src/test_opencl.cpp thing in the command line?

If I dumped the code inside an Xcode project and tweak the header to just "cl.hpp" it builds and runs, but I can't make it do it from the command line without getting a bunch of Undefined symbols for architecture x86_64: errors.

@yuchen-w
Copy link

Try including the 64 bit opencl library (opencl.lib) as an additional dependency in xcode or a separate make file

@kronocharia
Copy link
Author

How do I do that? / what goes into the makefile to do that.

Xcode sorts itself out, its great it knows how to build and run it, but I dont know how to tell it to run multiple mains, how are you doing that in VS?

@yuchen-w
Copy link

I added it as an additional dependency to the linker in VS. This was found in "Project Properties"

As for the multiple mains, I just excluded all of the files I didn't want building. I think I'm going to have to create separate projects within my VS solution for each of the mains if I want VS to sort itself out and build.

As for the makefile, I'm not sure how you would write it for cmake, but for nmake, I was able to build it by doing the following:

LDLIBS = OpenCL.lib
INC_DIR = .\opencl_sdk\include
CPPFLAGS = $(CPPFLAGS) /I$(INC_DIR)
bin\test_opencl.exe : src/test_opencl.cpp
    -mkdir bin
    $(CPP) $(CPPFLAGS) $** /Fe$@ /link $(LDFLAGS) $(LDLIBS)

@kronocharia
Copy link
Author

But in order to do the stuff, run by piping each executable into each other, there's no way of doing that in the debugger is there =/

@yuchen-w
Copy link

Hmm. I have't thought that far yet.

@darioml
Copy link
Contributor

darioml commented Feb 15, 2015

Working from me from the command line for the following:

# Makefile for posix and gcc

# Note on old compilers  *cough*  DoC  *cough* you might need -std=c++0x instead
CPPFLAGS = -I include -Wall -std=c++11 -framework OpenCL
LDFLAGS = 
# -lm to bring in unix math library, -ltbb to bring in tbb
LDLIBS = -lm

# Turn on optimisations
CPPFLAGS += -O2

bin/test_opencl : src/test_opencl.cpp
    -mkdir -p bin
    $(CXX) $(CPPFLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)

all : bin/test_opencl

is this what you mean?

@salmanarif
Copy link

@darioml that works for test_opencl.cpp but not for the other files if rules are added to make those. I get the following error with step_world.cpp for example:

c++ -I include -Wall -std=c++11 -framework OpenCL -O2 src/step_world.cpp -o bin/step_world -lm Undefined symbols for architecture x86_64: "hpce::LoadWorld(std::__1::basic_istream<char, std::__1::char_traits<char> >&)", referenced from: _main in step_world-b80129.o "hpce::SaveWorld(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, hpce::world_t const&, bool)", referenced from: _main in step_world-b80129.o "hpce::StepWorld(hpce::world_t&, float, unsigned int)", referenced from: _main in step_world-b80129.o ld: symbol(s) not found for architecture x86_64

@salmanarif
Copy link

Update:

Modifying the rules for step_world.cpp etc from this:
bin/step_world : src/step_world.cpp
to:
bin/step_world : src/step_world.cpp src/heat.cpp
results in successful compilation.

@m8pple m8pple closed this as completed in 361cd22 Feb 16, 2015
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

4 participants