Search on this site
Search in forums

Home » Community » Newbie corner » undefined reference errors when building (Linking has failed)
undefined reference errors when building Sun, 22 October 2017 20:56
 Y ++ Messages: 12Registered: June 2017 Promising Member
Hello,

I get error messages when building this upp example: https:// www.ultimatepp.org/srcdoc$ArrayFire_demo$ArrayFire$en-us.htm l I followed the instructions included about lib, path and include. MS Visual studio community 2015 is installed and compiles Arrayfire example 'helloworld_vs2013.sln' and others without error. I reread this https://www.ultimatepp.org/app$ide$GettingStarted$en-us.html#5_3 and this https://www.ultimatepp.org/app$ide$install$en-us.html 1. how to get rid of the errors having the example run? 2. the TheIDE installation page says "we really recommend using VS2015 C++ compiler (...) better supported by 3rd party libraries" , I followed instructions on this page but only MinGW and MinGWx64 show up in the builds method. How to configure this ? 3. should the last "visual studio code" be installed instead as recommended by MS ? (The screenshot there https://www.ultimatepp.org/app$ide$install$en-us.html is obsolete.)

Below is the error as displayed by TheIDE U++ version 11390 (64bits)(GCC)(C++11) on win8.1 64bits intel x64:

Toggle Spoiler

For information I have read (certainly not understood everything) these (old) posts about linking or external library:
https:// www.ultimatepp.org/forums/index.php?t=msg&goto=31309& ;
https:// www.ultimatepp.org/forums/index.php?t=msg&goto=9795&
https:// www.ultimatepp.org/forums/index.php?t=msg&goto=46340& ;
https:// www.ultimatepp.org/forums/index.php?t=msg&th=9524&st art=0&
and
https:// www.ultimatepp.org/forums/index.php?t=msg&goto=46601& ;

U++ version 11390 (64bits)(GCC)(C++11) on win8.1 64bits intel x64
Re: undefined reference errors when building [message #48887 is a reply to message #48883] Mon, 23 October 2017 08:54
 rafiwui Messages: 105Registered: June 2017 Location: Stuttgart, Germany Experienced Member
If you have MS Visual Studio 20xx installed (it works with 2017 just as nice as with 2015 on my PC) try using U++ for Windows without toolchain downloads and not the U++ for Windows with MinGW-w64 toolchain. That should work then.

Greetings
Daniel

[Updated on: Mon, 23 October 2017 09:31]

Report message to a moderator

Re: undefined reference errors when building [message #48888 is a reply to message #48887] Mon, 23 October 2017 09:36
 rafiwui Messages: 105Registered: June 2017 Location: Stuttgart, Germany Experienced Member
If you need the MinGW edition and just need the VS20xx compiler as well then the reason that U++ is not finding the compiler location automatically could be that you may not have installed VS on your system hard disk. That happened to me when I installed VS on a secondary. I had to give U++ the paths manually.

Greetings
Daniel
Re: undefined reference errors when building [message #48891 is a reply to message #48883] Mon, 23 October 2017 10:16
 koldo Messages: 3248Registered: August 2008 Senior Veteran
Dear Y++

In ArrayFire in U++ page there are some explanations about how to use ArrayFire in U++.

Following the messages you have included it seems that Include files are included, but compiler does not find Library files.

Have you set all folders as indicated?

Best regards
Iñaki
Re: undefined reference errors when building [message #48898 is a reply to message #48883] Mon, 23 October 2017 18:58
 Y ++ Messages: 12Registered: June 2017 Promising Member
Quote:
If you have MS Visual Studio 20xx installed (it works with 2017 just as nice as with 2015 on my PC)

Ok, I leave it as it is (2015) This answered the question 3. Thanks rafiwui.

Quote:
try using U++ for Windows without toolchain downloads and not the U++ for Windows with MinGW-w64 toolchain. That should work then.

Just tried (upp-win-11405) It does not show any build method too. I tried filling manually the "build methods" panel. The documentation https://www.ultimatepp.org/app$ide$GettingStarted\$en-us.html#5_3 is not very helpful and this post https:// www.ultimatepp.org/forums/index.php?t=msg&goto=46601& ; is confusing to me. I re-tried what it is said with the U++ without toolchain and I get this error:
o:\progs\upp\uppsrc\core\Core.h (45): fatal error C1189: #error :  This version of U++ REQUIRES C++11

May I ask a screenshot of a working MSC (x64) configuration ?

Quote:
you may not have installed VS on your system hard disk

Yes it can't. (disk space usage)

Quote:
I had to give U++ the paths manually.

That would partially answer the question 2. How to do it ? TheIDE documentation is not verbose on this. I unsuccessfully tried many paths. I need help on this if we can't figure why MinGWx64 doesn't work here.

Quote:
it seems that Include files are included, but compiler does not find Library files.

I trust you and I can't figure out how you see this. Is it because of the .o files ?

Quote:
Have you set all folders as indicated?

There isn't much error to do here as there are only two folder. I checked twice (more in fact). Can you confirm that it's anormal MinGWx64 cannot compile it as it's an example included in U++? And, should I take care about the All static/Shared libs/All shared settings in the "build methods" panel ?

U++ version 11390 (64bits)(GCC)(C++11) on win8.1 64bits intel x64
Re: undefined reference errors when building [message #48899 is a reply to message #48898] Mon, 23 October 2017 19:47
 rafiwui Messages: 105Registered: June 2017 Location: Stuttgart, Germany Experienced Member
This should be a working example of an edited configuration. I have it installed on an secondary as well so feel free to copy it to the folder where the exe of TheIDE is and edit the variables to your locations.
The parts starting with C:\ you probably don't have to change because windows is always installing these parts at the same location no matter where you install VS
• Attachment: MSVS17x64.bm

Greetings
Daniel

[Updated on: Mon, 23 October 2017 19:49]

Report message to a moderator

Re: undefined reference errors when building [message #48900 is a reply to message #48899] Tue, 24 October 2017 09:21
 Y ++ Messages: 12Registered: June 2017 Promising Member
Quote:
edit the variables to your locations.
The parts starting with C:\ you probably don't have to change
Done, I had to change all locations : "C:\..." locations aren't the same as I have VS2015 installed instead of your VS2017. In consequence I'm not sure as some specified folders where empty, I tried to find the more accurate. And It's seems there is some progress I get this error now (Helloworld example)
 (): Linking has failed
(): O:\upp-win-11405\upp\out\examples\AnimatedHello\MSVS17x64.Debug.Gui.Main.Noblitz\Hello.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'


U++ version 11390 (64bits)(GCC)(C++11) on win8.1 64bits intel x64
Re: undefined reference errors when building [message #48901 is a reply to message #48883] Tue, 24 October 2017 09:34
 Y ++ Messages: 12Registered: June 2017 Promising Member
Maybe something about MinGWx64 (the first question) :
when compiling it writes
GUI GCC DEBUG DEBUG_FULL WIN32
why "WIN32" ?

U++ version 11390 (64bits)(GCC)(C++11) on win8.1 64bits intel x64
Re: undefined reference errors when building [message #48902 is a reply to message #48901] Tue, 24 October 2017 10:20
 rafiwui Messages: 105Registered: June 2017 Location: Stuttgart, Germany Experienced Member
Hmm I don't know about the MinGW toolchain so I guess I can't help you there. But I may can send you my x86 config file this evening so you can try it with this.

Greetings
Daniel
Re: undefined reference errors when building [message #48903 is a reply to message #48900] Tue, 24 October 2017 10:53
 Oblivion Messages: 827Registered: August 2007 Experienced Contributor
Quote:
Quote:

edit the variables to your locations.
The parts starting with C:\ you probably don't have to change

Done, I had to change all locations : "C:\..." locations aren't the same as I have VS2015 installed instead of your VS2017. In consequence I'm not sure as some specified folders where empty, I tried to find the more accurate. And It's seems there is some progress I get this error now (Helloworld example)

(): O:\upp-win-11405\upp\out\examples\AnimatedHello\MSVS17x64.De bug.Gui.Main.Noblitz\Hello.obj : fatal error LNK1112: module machine type 'X86' conflicts with target machine type 'x64'

You need to build it in 64bit mode and link it with x64 libs (or 32-32bits, if that's what you intend. In short there is mismatch between the object file and library). Could you post your build method file (with *.bm extension) (if you are using Visual Studio to compile and link the external library, there is a notoriously overlooked switch that results in this error, if not; I may be able to help you if you provide your build)?

Best regards,
Oblivion

[Updated on: Tue, 24 October 2017 10:57]

Report message to a moderator

Re: undefined reference errors when building [message #48904 is a reply to message #48903] Tue, 24 October 2017 10:57
 rafiwui Messages: 105Registered: June 2017 Location: Stuttgart, Germany Experienced Member
Oblivion wrote on Tue, 24 October 2017 10:53
You need to link it with x64 libs.

But shouldn't that be set correct because I am working with basically the same paths and it works?

Greetings
Daniel
Re: undefined reference errors when building [message #48905 is a reply to message #48904] Tue, 24 October 2017 11:10
 Oblivion Messages: 827Registered: August 2007 Experienced Contributor
Quote:
Re: undefined reference errors when building Tue, 24 October 2017 11:57
rafiwui
Oblivion wrote on Tue, 24 October 2017 10:53

You need to link it with x64 libs.

But shouldn't that be set correct because I am working with basically the same paths and it works?

Not sure...
There may be a left-over object (sometimes it is simply a matter of cleaning upp.out.)
Or usually it is about wrong -or messed up for some reason- paths. (I can't really say more without seeing the bm file.)

Best regards,
Oblivion

[Updated on: Tue, 24 October 2017 11:11]

Report message to a moderator

Re: undefined reference errors when building [message #48906 is a reply to message #48905] Tue, 24 October 2017 14:31
 Oblivion Messages: 827Registered: August 2007 Experienced Contributor
Did you check this:
.../windows kits/10/bin/x86
---
^
|



You seem to be using wrong toolchain?
Shoudn't it be x64?

Re: undefined reference errors when building [message #48907 is a reply to message #48906] Tue, 24 October 2017 14:35
 rafiwui Messages: 105Registered: June 2017 Location: Stuttgart, Germany Experienced Member
Interesting. I thought I changed all but seems like I missed that one.
And also interesting that it works on my PC

Greetings
Daniel

[Updated on: Tue, 24 October 2017 14:35]

Report message to a moderator

Re: undefined reference errors when building [message #48911 is a reply to message #48907] Wed, 25 October 2017 18:10
 Y ++ Messages: 12Registered: June 2017 Promising Member
Hello,
Quote:
There may be a left-over object (sometimes it is simply a matter of cleaning upp.out.)

Cleaned.

Then :
attached : up.zip

• console + errors + MINGWx64.bm from U++ for Windows with MinGWx64 toolchain (arrayfire example)
• console + errors + MSVS17x64.bm from U++ for Windows without toolchain (.bm file from rafiwui with edited paths) (animatedHello exemple)

1. But you, are you able to run the "examples-bazaar\ArrayFire_demo" example, if yes with MinGWx64 or/and the VS compiler ? I would prefer to do without VS if we can make MinGWx64 work.
2. Since the build rafiwui shared is for vs2017, I consider removing vs2015 and install the "Build Tools for Visual Studio 2017" instead. It would free me disk space and (I think) make it easier to match configuration. Hence I wait for your advice about that before attempting it.
3. Why this error: "O:\PROGS\ArrayFire\v3\include/af/defines.h (29): warning: "DEPRECATED" redefined" since there is the "using namespace" instruction ?

Best regards,
Y ++
• Attachment: up.zip

U++ version 11390 (64bits)(GCC)(C++11) on win8.1 64bits intel x64

[Updated on: Wed, 25 October 2017 19:02]

Report message to a moderator

Re: undefined reference errors when building [message #48912 is a reply to message #48906] Wed, 25 October 2017 19:11
 Y ++ Messages: 12Registered: June 2017 Promising Member
Oblivion wrote on Tue, 24 October 2017 14:31
Did you check this:
.../windows kits/10/bin/x86
---
^
|



You seem to be using wrong toolchain?
Shoudn't it be x64?

And, I get the same error message when changing the path

U++ version 11390 (64bits)(GCC)(C++11) on win8.1 64bits intel x64
Re: undefined reference errors when building [message #48913 is a reply to message #48911] Wed, 25 October 2017 21:09
 Oblivion Messages: 827Registered: August 2007 Experienced Contributor
Hello Y ++

I have a litte experience with arrayfire (on OpenCL).
IIRC, ArrayFire does not yet work with MinGW C++ (it has some problem with name mangling if you are using precompiled binaries, so you'll get a lot of linker error ("undefined reference" errors.).). (Unless you also compile the libs from arrayfire source)
On the other hand, both Build Tools, and Visual Studio 2017 will work with it. You should consider upgrading.

Please find attached a MSC bm file for Visual Studio 2017. Check out the paths, it'll give you the idea for also MS Build Tools (they are mostly same.). No other setting is required on my machine:

Best Regards,

Oblivion
• Attachment: MSC.bm

[Updated on: Thu, 26 October 2017 11:55]

Report message to a moderator

Re: undefined reference errors when building [message #48915 is a reply to message #48883] Thu, 26 October 2017 18:47
 Y ++ Messages: 12Registered: June 2017 Promising Member
Thank you Oblivion and rafiwui for your help
it works with MS build tools 2017.

@ Koldo
: do you think it is worth to put a note on this in the doc ? ( I've seen one can edit the srcdoc.tpp )

Quote:
ArrayFire does not yet work with MinGW

U++ version 11390 (64bits)(GCC)(C++11) on win8.1 64bits intel x64
Re: undefined reference errors when building [message #48948 is a reply to message #48915] Wed, 08 November 2017 13:23
 koldo Messages: 3248Registered: August 2008 Senior Veteran
Sorry for the delay. Comment is just updated. It will be visible tomorrow.

Best regards
Iñaki
 Previous Topic: u++ in appveyor ? Next Topic: Link Libraries
Goto Forum:

Current Time: Tue Jan 19 09:46:43 CET 2021

Total time taken to generate the page: 0.00876 seconds