You are not logged in.

#1 2017-12-29 00:55:41

GameCodingNinja2
Member
Registered: 2017-12-29
Posts: 20

[SOLVED] Netbeans will not recognize C++ build as an executable

I spent the last few days setting up a new Arch Linux system using xfce4 which was an awesome experience. I can't imaginge ever touching another distro again.

I use Netbeans as my IDE to develop C++ apps. Compiling my cmake projects works as expected. I can run the executable from command line but not from Netbeans. Looking at the file via the xfce4 file manager, it displays as a "shared library" and doesn't use the executable icon.

As a test, I generated a simple C++ "hello world" project and compiled it. This doesn't use cmake. The executable still displays as a "shared library" via xfce4 file manager but netbeans will run it and I can place a break point.

I don't know if I'm having a permissions issue or just stumbled into a Netbeans bug. I can't imagine it would be a cmake problem considering the cmake projects won't run in Netbeans but a simple "hello world" will.

Any help would be greatly appreciated.

Last edited by GameCodingNinja2 (2017-12-31 01:49:05)

Offline

#2 2017-12-29 09:53:35

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

Looking at the file via the xfce4 file manager, it displays as a "shared library" and doesn't use the executable icon.

Yeah, that's nonsense. Use "file" to read the magic byte - which however does not indicate "runnability" either.

Your post lacks the crucial bit, what does

not from Netbeans

mean? How do you attempt to run it and what's the error message in return?

Offline

#3 2017-12-29 20:55:47

GameCodingNinja2
Member
Registered: 2017-12-29
Posts: 20

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

Running "file" on the executable returns:
ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=a0daf6facd0b5ada57c6f58a4c58fc3fe34cc5b9, with debug_info, not stripped

The "Hello World" test project that does run in Netbeans returns: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=fe0e6106e5abf55b1a463e84c71d7edfb025f516, with debug_info, not stripped

"not from Netbeans" means Netbeans doesn't recognize the generate file as an executable. When a project is built for the first time, Netbeans brings up a dialog box asking you to select the executable from a list of files. Normally there's a few things listed and you just select the executable. This is a one time event when creating a new project. This time the dialog displays empty. There is a browse button but making my way to the executable, it won't see it unless view "all files" as the filter. Selecting the file, Netbeans says it's not an executable.

Ok, I think I know what's going on here. I stumbled upon some info and there's a thing known as an "executable shared library". This might be a new thing and GCC looks be defaulting to it. This would explain what I'm experiencing and why my executable which will run from command line is described as a "shared library". Now all I need to do is force it to generate an old fasion executable.

Last edited by GameCodingNinja2 (2017-12-29 21:16:23)

Offline

#4 2017-12-29 21:23:47

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

PIE compiled executables look like shared objects (unpredictable entry point) and that's what likely "confuses" the filemanager (on top of libmagic)

As for netbeans:
ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=a0daf6facd0b5ada57c6f58a4c58fc3fe34cc5b9, with debug_info, not stripped
ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=fe0e6106e5abf55b1a463e84c71d7edfb025f516, with debug_info, not stripped

The (vast) majority of my binaries in /usr/bin (and /usr/lib !) report as SYSV, only few as GNU/Linux - I guess netbeans falsely looks for that specific pattern?
You could try to create more (randomly complex) "hello world" variants and see  whether netbeans willingness to take them as executable relates to this token.

Offline

#5 2017-12-29 22:45:09

GameCodingNinja2
Member
Registered: 2017-12-29
Posts: 20

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

I'm sure most of your binaries will report as "ELF 64-bit LSB executable". As for the Netbeans "Hello World" test and since it's handling all the makefile generation, it's just blindly using the end product. If I use Netbeans to load this very file, it rejects it and says it's not an executable.

Well, atleast now I know what's going on. I'm trying to see if there is a way to tell CMake to make an "ELF 64-bit LSB executable" vs an "ELF 64-bit LSB shared object".

Offline

#6 2017-12-29 22:50:17

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

Not half as much as SYSV.
Don't compile -pie -fPIE, https://cmake.org/cmake/help/v3.0/prop_ … _CODE.html should do.

Offline

#7 2017-12-30 00:35:43

GameCodingNinja2
Member
Registered: 2017-12-29
Posts: 20

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

That was the ticket. Needed to add "-no-pie" to the CMAKE_CXX_FLAGS.

Thanks for your help. smile

Offline

#8 2017-12-30 09:26:56

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

Notice that position independent code is not a feature that merely exists to break netbeans.
You want to keep building pie and ask netbeans to fix their stuff.

Offline

#9 2017-12-31 00:58:39

GameCodingNinja2
Member
Registered: 2017-12-29
Posts: 20

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

Agreed. I'll post this in their forums.

How do I mark this post as [SOLVED]?

Last edited by GameCodingNinja2 (2017-12-31 01:10:46)

Offline

#10 2017-12-31 01:39:03

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,634

Re: [SOLVED] Netbeans will not recognize C++ build as an executable

Edit your first post.  There is an option to edit the thread title (on the first post of a thread only) and just prepend [SOLVED] to the title

Last edited by ewaller (2017-12-31 01:39:43)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB