Create Your First Project
HOOPS Exchange is an explicitely load dynamic C library. This means that the main binary file is programmatically loaded at runtime from user code. In concrete words, that implied the following:
At compile time, your compiler only needs to know the location of header files (include/ folder)
At link time, nothing is necessary
At run time, your environment needs to know the location of the binaries (bin/ subfolder)
The following sections provide the most standard ways to prepare your environment for an new HOOPS Exchange application.
Prerequisites
First, make sure you have correctly set up your environment.
Todo
Create the Visual Studio (Windows) section about Prerequisites
Check your system documentation to install the make
command as well as the base C development tools.
Also, make sure your development environment is supported by HOOPS Exchange.
Todo
Create the Xcode (macOS) section about Prerequisites
Make sure you downloaded and installed CMake for your environment. Also, check Supported Platforms and Compiler Information to see which CMake generator is available according to your build system and that you installed the development tools you need.
Creating the Project
Todo
Create the Visual Studio (Windows) section about Creating the Project
Make a folder for your new project, and create a file called Makefile with the following content:
CC = gcc
PROJECT = ExchangeApplication
SRC = main.c
EXCHANGE_INSTALL_DIR =
CFLAGS = -I$(EXCHANGE_INSTALL_DIR)/include
LDFLAGS =
all: $(PROJECT)
$(PROJECT): $(SRC)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
clean:
rm -f $(PROJECT)
.PHONY: all clean
In the same folder, create another file called main.c.
Todo
Create the Xcode (macOS) section about Creating the Project
Make a folder for your new project, and create a file called CMakeLists.txt with the following content:
cmake_minimum_required(VERSION 3.18)
project(ExchangeApplication C)
set(EXCHANGE_INSTALL_DIR "" CACHE PATH "Path to Exchange directory")
add_executable(ExchangeApplication main.c)
target_include_directories(ExchangeApplication PRIVATE "${EXCHANGE_INSTALL_DIR}/include")
In the same folder, create another file called main.c.
The Source File
Open main.c from our text editor and write the following content:
#include <stdio.h>
#include <A3DSDKLoader.h>
int main(int argc, char* argv[])
{
if(A3DSDKLoadLibraryA(EXCHANGE_BINARY_DIR)) {
A3DInt32 major, minor;
A3DDllGetVersion(&major, &minor);
printf("HOOPS Exchange %d.%d loaded\n", major, minor);
A3DSDKUnloadLibrary();
}
return 0;
}
Build and Run
Todo
Create the Visual Studio (Windows) section about Build and Run
From your command line interface, change to the directory containing your Makefile and run the following command:
make EXCHANGE_INSTALL_DIR=path/to/exchange
path/to/exchange is the folder path to your Exchange installation directory (the folder containing include/).
Todo
Create the Xcode (macOS) section about Build and Run
Generate with CMake GUI
Open the CMake application.
Configure the source directory to your project folder and the build directory to any folder of your choice (preferably empty).
Run Configure. A pop-up dialog asks for your build environment. Choose the one that fits your compiler and validate.
Once the configuration is done, configuration variable appears in the center table.
Look for EXCHANGE_BINARY_DIR
and set it to the installation folder of Exchange.
The path must correspond to the folder containing include/.
Run Generate and open your newly generated project. It is located in the folder you previously set as the build directory. If you use an IDE, such as Visual Studio, chances are that you can directly open it from CMake using the Open Project button.
Compile and run your program. You should see Exchange version appearing in the standard output.
You’re ready to jump to our next tutorial: Print Structure.
Generate with CMake CLI
From your command line interface, change to any directory you want to generate the project build files (preferably empty) and run the following command:
cmake path/to/project -DEXCHANGE_INSTALL_DIR=path/to/exchange
path/to/projet is the folder path to your project root (the folder containing your CMakeLists.txt file and
path/to/exchange is the folder path to your Exchange installation directory (the folder containing include/).
You can also select your development environment with the -G
option.
If not set, the most relevant is choosen according to your operating system.
Once generated, your project is available in your current directory.
Compile and run your program following the instructions provided by your generator.
Upon running your program, you should see Exchange version appearing in the standard output.
Todo
Display a screenshot of the expected result