undefined reference function

Discussion to talk about software related topics only.
RebootExpert
Posts: 78
Joined: Fri Oct 09, 2020 2:57 pm

undefined reference function

Post by RebootExpert »

according to this thread in wolfssl forum https://www.wolfssl.com/forums/topic140 ... -pair.html
I should be able to use the function wolfSSL_CTX_check_private_key() to validate the ssl key pairs. I included the header file. and linked to the library cryptolib.a. However I got the undefined reference linker error. Any ideas what's wrong?
RebootExpert
Posts: 78
Joined: Fri Oct 09, 2020 2:57 pm

Re: undefined reference function

Post by RebootExpert »

I am using 2.9.3
User avatar
Jon
Posts: 79
Joined: Mon Feb 05, 2018 10:54 am

Re: undefined reference function

Post by Jon »

Hi RebootExpert,

To use this function, you'll need to undefine NO_FILESYSTEM in nburn\include\crypto\platform\<platform>.h and then rebuild the crypto libraries.

In the next release of our tools, this will be used in the function

Code: Select all

IsSSL_CertNKeyValid()
, so you'll be able to use that to the same effect if you like.

Kind Regards,
Jon
RebootExpert
Posts: 78
Joined: Fri Oct 09, 2020 2:57 pm

Re: undefined reference function

Post by RebootExpert »

Hi Jon, I am using MOD54415 and there's only a user_settings.h header file in the directory of C:\nburn\include\crypto\platform\MOD5441X
So I undefine NO_FILESYSTEM in the file. and rebuild the libraries. Same error occur when I try to use it.

There's #ifndef directive check the NO_CERTS macro around the declaration and definition of wolfSSL_CTX_check_private_key()
But NO_CERTS is already undefined by default in user_settings.h
User avatar
Jon
Posts: 79
Joined: Mon Feb 05, 2018 10:54 am

Re: undefined reference function

Post by Jon »

Hi RebootExpert,

Sorry about that, the file you mentioned is the correct one. When you did the rebuild, is that from the command line or through NBEclipse? It shouldn't matter, but I'm just trying to collect as much info as possible. Would it be possible for you to send me your project code and your user_settings.h file?

You can email them directly to me at jcox(at)netburner.com. I'd like to see if I can replicate the issue you're experiencing.

Kind Regards,
Jon
RebootExpert
Posts: 78
Joined: Fri Oct 09, 2020 2:57 pm

Re: undefined reference function

Post by RebootExpert »

Hi Jon,
I rebuild the libraries through NBEclipse IDE. Here's my simple project I just made having the same error.

Code: Select all

#include <predef.h>
#include <stdio.h>
#include <ctype.h>
#include <startnet.h>
#include <autoupdate.h>
#include <dhcpclient.h>
#include <smarttrap.h>
#include <taskmon.h>
#include <NetworkDebug.h>

#include <crypto/ssl.h>

extern "C" {
void UserMain(void * pd);
}

const char * AppName="validation";

bool validation()
{
	WOLFSSL_CTX* ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method());
	int isValid = wolfSSL_CTX_check_private_key(ctx); //undefined reference error
	wolfSSL_CTX_free(ctx);
	return isValid == WOLFSSL_SUCCESS;
}

void UserMain(void * pd) {

    InitializeStack();
    GetDHCPAddressIfNecessary();
    OSChangePrio(MAIN_PRIO);
    EnableAutoUpdate();
    StartHTTP();
    EnableTaskMonitor();

    #ifndef _DEBUG
    EnableSmartTraps();
    #endif

    #ifdef _DEBUG
    InitializeNetworkGDB_and_Wait();
    #endif

    iprintf("Application started\n");
    
    validation();
    
    while (1) {
        OSTimeDly(TICKS_PER_SECOND);
    }
}

RebootExpert
Posts: 78
Joined: Fri Oct 09, 2020 2:57 pm

Re: undefined reference function

Post by RebootExpert »

and the header file for MOD5441X
user_settings.h
(7.3 KiB) Downloaded 150 times
User avatar
Jon
Posts: 79
Joined: Mon Feb 05, 2018 10:54 am

Re: undefined reference function

Post by Jon »

Hey RebootExpert,

When you rebuild the system libraries in NBEclipse, does it list the platform that you've selected for the project during the rebuild, or does it show the CB34EX? This can happen if you select rebuild system libraries without having a project selected.

Just to make certain we're rebuilding the SSL libraries with the correct user_settings.h selected, would you mind trying the following:
Open a command terminal
Type

Code: Select all

set NBROOT
and make sure it lists your NNDK install directory.
Type

Code: Select all

set PLATFORM
and make sure it lists the MOD5441x. If it doesn't, type

Code: Select all

set PLATFORM=MOD5441X
Then navigate to

Code: Select all

<nndk_install>\system
and type

Code: Select all

make libs
This will force the library to be rebuilt with the settings using the MOD5441X folder specifically. Finally, go back to your project in NBEclipse and try to rebuild the project only, not the system libraries.

Kind Regards,
Jon
RebootExpert
Posts: 78
Joined: Fri Oct 09, 2020 2:57 pm

Re: undefined reference function

Post by RebootExpert »

I follow the steps. project still fail to compile.
Microsoft Windows [Version 10.0.19042.928]
(c) Microsoft Corporation. All rights reserved.

C:\WINDOWS\system32>set NBROOT
NBROOT=C:\nburn
NBROOTMINGW=C:\nburn

C:\WINDOWS\system32>set PLATFORM
PLATFORM=MOD5441X

C:\WINDOWS\system32>cd c:/nburn/system

c:\nburn\system>make libs
make[1]: Entering directory 'c:/nburn/system/cryptolib'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/cryptolib'
make[1]: Entering directory 'c:/nburn/system/debugLibrary'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/debugLibrary'
make[1]: Entering directory 'c:/nburn/system/lua'
c:/nburn/gcc-m68k/bin/make -C libraries system
make[2]: Entering directory 'c:/nburn/system/lua/libraries'
make[2]: Nothing to be done for 'system'.
make[2]: Leaving directory 'c:/nburn/system/lua/libraries'
make[1]: Leaving directory 'c:/nburn/system/lua'
make[1]: Entering directory 'c:/nburn/system/nb-libxively'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/nb-libxively'
make[1]: Entering directory 'c:/nburn/system/nbwifi'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/nbwifi'
make[1]: Entering directory 'c:/nburn/system/sshLibrary'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/sshLibrary'
make[1]: Entering directory 'c:/nburn/system/webclient'
make[1]: Nothing to be done for 'system'.
make[1]: Leaving directory 'c:/nburn/system/webclient'

c:\nburn\system>
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: undefined reference function

Post by TomNB »

Hello,

I am not sure about 2.9.3 as I don't have anything that old, but in 2.9.4 your application code works for me in nbeclipse with the only change being to comment out the #define #include NO_FILESYSTEM as Jon indicated. Although from the lib compilation you posted, it looks like the libs built, so that part is a bit confusing to me. I'm guessing after that your app still had a link error? Sorry this isn't more helpful, but I do not have access to 2.9.3.
Post Reply