Addon_config.mk: how to add directory for Visual Studio "Additional Library Directories"?


#1

new to makefiles…

I need to point VS2015 to:
$(RSSDK_DIR)lib\$(Platform)
in its “Additional Library Directories” property for my addon (which uses the Intel RealSense SDK)

I’m trying to do this by adding it somewhere in addon_config.mk.

I tried:

common:
    ADDON_LDFLAGS = -l$(RSSDK_DIR)lib\$(Platform)

and

vs:
    ADDON_LIBS += $(RSSDK_DIR)lib\$(Platform)

neither seems to work (doesn’t show up in the property when I check in VS)

Here’s a screen shot:

(note that the Additional Include Directories portion of that image is working using ADDON_INCLUDES += $(RSSDK_DIR)include)


#2

i think there was a problem with reading environment variables in the project generator that comes with 0.9.x can you try if the one in the nightly builds works for this? you can just copy the new PG to your 0.9.x download and it’ll work for that version


#3

Just tested with the nightly, and works perfectly using

vs:
    ADDON_LIBS += $(RSSDK_DIR)lib\$(Platform)

thanks!


#4

Actually, I spoke too soon.

The PG from the nightly is reading vs: ADDON_LIBS into Additional Library Directories in VS2015, but it’s missing the $(Platform) part.
i.e.

vs:
    ADDON_LIBS += $(RSSDK_DIR)lib\$(Platform)

gives me:

C:\Program Files (x86)\Intel\RSSDK\lib

in Additional Library Directories.

I want that to be

C:\Program Files (x86)\Intel\RSSDK\lib\$(Platform)

Two notes: $(RSSDK_DIR) is an environmental variable created by the Intel RealSense SDK installer, whereas $(Platform) is a Visual Studio macro that should translate to Win32 or x64 depending on build platform.

I figured it’s looking for an environmental variable for $(Platform) and can’t find it, so it drops it.
But I tried escaping the $ using $$(Platform) - no luck.

The behavior is a bit strange in general though… when I try:

ADDON_LIBS += $(RSSDK_DIR)lib

so removing the \$(Platform) part, I get:

C:\Program Files (x86)\Intel\RSSDK

So it is missing the lib folder at the end…

Strange, because

ADDON_INCLUDES += $(RSSDK_DIR)include

works perfectly and gives me

C:\Program Files (x86)\Intel\RSSDK\include

in Additional Include Directories.

Any thoughts?


#5

mmh, yes we could add $$ to add variables that won’t be translated by the PG, can you open an issue in github? not sure why it would not add lib when not adding the second variable at the end though, i’ll take a look when i have a moment. if you can add it to the same issue?


#6

Ah, it would be lovely to have the $$ escape - will open that issue in github.

But in the meantime I actually solved my specific problem:

I realized PG is parsing the lib path into folder\filename.

Everything after the last \ was ending up in the Linker > Additional Dependencies property in VS, which makes sense (just not for my case). That property is a little hidden in VS so I missed it.

To avoid the parsing, I can just write the path with a trailing slash.

ADDON_LIBS += $(RSSDK_DIR)lib\$(Platform)\

and in Linker > Additional Library Directories, I end up with

C:\Program Files (x86)\Intel\RSSDK\lib\$(Platform)

Which is correct, with the $(Platform) kept as is.

But this only works for me because there are 2 environmental variables in my lib path.

I spent some time looking through the ofAddon.cpp code in PG and realized that the reg ex match for the $(env_var) sequence only looks for the first instance in the string (see line 180).

So it’s finding $(RSSDK_DIR) and then skipping $(Platform). Probably pretty rare to have two environmental variables, so maybe no need to address that issue.


#7

ah, ok yeah ADDON_LIBS refers to library files not to directories that’s why the PG is cutting the path, perhaps it should be smarter and not cut it unless the final part has an extension or is a file in the file system.


#8

The reason I have a directory there is because I’m adding the library file with a MSVC compiler directive based on the build configuration:

#ifdef _DEBUG
#pragma comment(lib, "libpxcmd_d.lib")
#else
#pragma comment(lib, "libpxcmd.lib")
#endif

Would be nice to avoid that though.
Any way to specify debug vs release in addon_config.mk?

Sorry, trying to figure all this out as I go


#9

no worries there’s not much documentation for this and i keep adding new features as needed. i’ve tried in the past to add debug and release configs to the config file (the filesystem parser already supports it) but never got to add it.

also probably an ADDONS_LIBRARY_PATHS would be useful. with gcc/clang you can just use ADDON_LDFLAGS=-L SomePath to add a library path but i’m not sure you can do that with vs and it would be easier with a specific flag anyway. can you add that to your issue?


#10

I’m in a similar situation want to distinguish debug lib and release lib in vs since vs is sensitive to debug/release configuration.

I tried ADDON_LDFLAGS=-L SomePath, but it seems not working.
ADDONS_LIBRARY_PATHS neither.

Tested on Windows 10, vs 2017, oF 0.10.1

hmmm…


#11

Hey, oddly enough, I was just working on updating libs on a fork of the ofxLibwebsockets addon –
and using separate Debug and Release folders is working for me in VS2017 + oF 0.10.1 –

the folder structure is like:

Project Generator seems to be able to parse that structure correctly for me without any addon_config.mk tweaks. My VS project has the right library path for each build config.

Specifically, the library search path changes in VS2017 under project Properties > Linker > General > Additional Library Directories when I switch build between Debug and Release.


#12

Wow nice catch!
I was using C:Program File/someLib/blurblur
Instead of copying all librarie files into addon local directory(lib, include).

I will try your idea. Thanks!


#13

yes that works we use it for ofxOpenCv, the addons config file is still not able to express different configs for release and debug but the PG and the visual studio plugin will parse it from the file system properly