Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Adding objects to your RackAFX Project
No permission to create posts
June 11, 2013
1:36 am
Avatar
W Pirkle
Admin
Forum Posts: 143
Member Since:
January 28, 2017
sp_UserOfflineSmall Offline

This comes up a lot - you want to add some object files (.h/.cpp pairs) into your RackAFX project to get some of your existing objects/plug-ins into your project or maybe to add some 3rd party objects. There are different ways to structure this and it can be tricky.

***Flat Directory*** you keep all .cpp and .h files in one folder, the RackAFX project folder. This is the safest way to do it.

1. manually copy the .h and .cpp files from their source location into your project folder
2. right click on the solution in Solution Explorer in VS and choose Add->Existing Item
3. browse to your own project folder (it should default there) and select all the .h and .cpp files you copied over
4. to use any object, the #include statement looks like this:

#include "MyNewObject.h"

***Nested Directory*** suppose you want to structure your directories in your project folder. You create a new folder named "MoreObjects" and you want to use that to store your extra objects.

1. manually copy the .h and .cpp files from their source location into your nested subfolder
2. right click on the solution in Solution Explorer in VS and choose Add->Existing Item
3. browse to your subfolder and select all the .h and .cpp files you copied over
4. to use any object, the #include statement looks like this:

#include "./MoreObjects/MyNewObject.h"

Notice the "./" at the front of the #include line - that's a relative path marker

You DO NOT want to do this if your other objects #include a common file, like pluginconstants.h -- you will get a compiler error saying it can't open the .h file; if you copy the .h file into that sub-folder then you will get a ton of errors involving trying to include pluginconstants.h more than once. The #pragama once directive is file dependent so it doesn't prevent the second identical pluginconstants.h from getting compiled.

***Outside Directory*** this is the trickiest one, you want to keep your files in another folder outside of the project folder. You want to do this because you are sharing these files with multiple projects, or you want to make sure bug fixes or changes to these objects are automatically fixed/changed for the other projects. This is a common issue. You can do this in a similar manner:

1. right click on the solution in Solution Explorer in VS and choose Add->Existing Item
2. browse to your outside folder and select all the .h and .cpp files you want to use

Now the tricky part:for the #include you have more options; if the outside folder is in a parallel directory to your projects folder, that is, the outside folder is in the same outer folder as your project folder, then you would write:

#include "../OtherFolder/MyNewObject.h"

"../" gives the relative location, meaning in the same folder as the RackAFX project folder

What if your outside directory is outside the projects folder? For example, your RackAFX Project folder is:

C:\MyProjects\RackAFX Projects

and your other folder is at

C:\HandyObjects

then the #include looks like:

#include "../../HandyObjects/MyNewObject.h

"../../" means one directory above my current directory
so
"../../../" means two directories above my current directory, etc...

Those relative paths are a pain; you can also specify the absolute path:

#include "C:/HandyObjects/MyNewObject.h"

Forum Timezone: America/New_York

Most Users Ever Online: 36

Currently Online:
5 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Skyler: 47

Peter: 41

Derek: 41

clau_ste: 39

Frodson: 38

Gwen: 32

EZB: 24

lppier: 23

Msaldaña: 18

Jorge: 17

Member Stats:

Guest Posters: 1

Members: 477

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 30

Topics: 483

Posts: 1877

Newest Members:

Jaggxn, sam, annaharris, Marie Weaver, kev, Steven, Mr Anderson, mguy, omelc

Moderators: W Pirkle: 143

Administrators: Tom: 65, JD Young: 80, Will Pirkle: 0, W Pirkle: 143