Author Topic: linking files  (Read 1572 times)

Vampire

  • Newbie
  • *
  • Posts: 11
    • View Profile
linking files
« on: March 17, 2016, 19:34:39 »
suppose MyPlugin.h has a dependency on MyClass.h

what's the standard way to link this file in?


[would it be something like:
DEPS = MyClass.h
OBJ = MyPlugin.o MyClass.o
in one of the Makefiles?
]

cannam

  • Administrator
  • Sr. Member
  • *****
  • Posts: 266
    • View Profile
Re: linking files
« Reply #1 on: March 18, 2016, 16:49:58 »
The way the skeleton files in the v2.6 SDK are arranged, the platform-specific stuff goes in Makefile.osx, Makefile.linux etc and the platform-independent stuff goes into Makefile.inc, which is included by the other Makefiles.

In most cases, any header and object files you add are going to be needed regardless of platform, and so should go in Makefile.inc. There are variables PLUGIN_SOURCES and PLUGIN_HEADERS near the top that can be extended with further headers and .c/.cpp files (the .o files will be deduced from the .c/.cpp names) or you can add .o files directly to PLUGIN_OBJECTS further down.

I hope that addresses your question!

Vampire

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: linking files
« Reply #2 on: March 21, 2016, 14:44:26 »
thanks Chris! - working well now

I found it useful

1. in Makefile.osx, define a variable
OTHER_SRC_DIR := PathToMyFolder

I actually just added a folder to the 'skeleton' folder example and copied source, but you could add a path to existing source also.

2. in Makefile.inc
CXXFLAGS   := <other flags> -I$(OTHER_SRC_DIR)

3. add to: PLUGIN_LDFLAGS   :=  <other stuff> -framework Accelerate

(as I used the Apple internal framework Accelerate)

4. as Chris explained above
PLUGIN_SOURCES := MyPlugin.cpp $(OTHER_SRC_DIR)/ExtraSrcCode.cpp

Then the command

make -f Makefile.osx

will generate required .o objects


I'm not using gmake (any reason to pursue that on Mac OS X?) over 'make -f ...'?