2

I am currently working on a Linux port of an application I am developing. The app is written in c++ and works great on windows and mac. On Windows I am using Visual Studio, Xcode on mac, and Netbeans on Ubuntu Linux. My problem is that in both Xcode and Visual studio I can have a resource folder in my project relative to my code:

_Project
__>ResourceFolder
____>Image.png
__>SourceFolder
____>main.cpp

and I can pass the path "ResourceFolder/Image.png" to my load function, which receives the actual location of the image data, which to my knowledge gets embedded into the executable at compile time. When I import my code into the Netbeans 'Source Files' folder on Ubuntu however, my path breaks and I get a segmentation error from my image loading function.

I am currently working around my loading problem by placing my resource files in a directory next to the executable that gets generated, but I prefer not to use the filesystem, rather embedding my resources into the executable so people cannot so easily modify my app. I have tried changing the path many times to reference the files in my project but to no avail.

Does Netbeans support embedding images and other resources added to the project filesystem into the Linux executable and relative access paths similar to Visual Studio, or is a more complicated work around required?

Hackstaar
  • 233
  • 2
  • 13
  • It's not a NetBeans problem - you need to force the compiler to do that. Please see: https://stackoverflow.com/questions/4158900/embedding-resources-in-executable-using-gcc – HEKTO Dec 28 '17 at 17:25
  • @HEKTO l had seen that question before and was able to successfully embed my resources into the program by hex-dumping each file into a header using xxd -i myresource.png > myresource.h, then include the file and access the data and length. This only worked for me because the function I used to load my resource had a raw data version where I could pass in the hex. This is no where near as easy as in VS and is not considered optimal because some loading functions take in a path and don’t have a raw data version. Configuring Netbeans to translate directories into headers might be an option... – Hackstaar Dec 28 '17 at 23:13

0 Answers0