jjames01
Posts: 4
Joined: Sun Dec 10, 2017 9:41 pm

Error visual studio Pi3

Mon Dec 11, 2017 7:51 pm

Hello once again . Im trying to compile a simple code for rfid card and export it to my Pi 3 through ssh using visualGDB. but i get the following error . Ive included the header file for the card and the necessary library files.
Severity Code Description Project File Line Suppression State
Error ld returned 1 exit status rfidtest C:\Users\Barry.I\Documents\rfid-test\rfidtest\rfidtest\collect2.exe 1

1>------ Build started: Project: rfidtest, Configuration: Debug VisualGDB ------
1>Linking ../VisualGDB/Debug/rfidtest...
1>c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lMFRC522
1>c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -l-Wl,--rpath=$ORIGIN
1>collect2.exe : error : ld returned 1 exit status
1>Done building project "rfidtest.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




Code: Select all


#include <unistd.h>
#include <MFRC522.h>
//#include <wiringPi.h>

void delay(int ms) {
#ifdef WIN32
	Sleep(ms);
#else
	usleep(ms * 1000);
#endif
}

int main() {
	MFRC522 mfrc;

	mfrc.PCD_Init();

	while (1) {
		// Look for a card
		if(!mfrc.PICC_IsNewCardPresent())
		  continue;

		if (!mfrc.PICC_ReadCardSerial())
			continue;

		// Print UID
		for(byte i = 0 ; i < mfrc.uid.size ; ++i) {
			if (mfrc.uid.uidByte[i] < 0x10) {
				printf(" 0");
				printf("%X", mfrc.uid.uidByte[i]);
			}
			else {
				printf(" ");
				printf("%X", mfrc.uid.uidByte[i]);
			}
      
		}
		printf("\n");
		delay(1000);
	}
	return 0;
}

any help plz

User avatar
topguy
Posts: 4557
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Error visual studio Pi3

Tue Dec 12, 2017 9:25 am

Code: Select all

1>c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lMFRC522
1>c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -l-Wl,--rpath=$ORIGIN
Your GCC/Linker options has some problems. For example I believe "-l-Wl,--rpath=$ORIGIN" should contain spaces between each option like this:

Code: Select all

-l -Wl, --rpath=$ORIGIN
Also, if you want to link with a library (MFRC522) during crosscompiling you have to tell GCC where to find it, and it has to be copied to your computer.

jjames01
Posts: 4
Joined: Sun Dec 10, 2017 9:41 pm

Re: Error visual studio Pi3

Tue Dec 12, 2017 7:40 pm

thank you for your reply topguy. I am using visual studio community 17 and cross compiling with rpi 3 when you say linker/gcc options i cant find that under the settings. I got it to recognize the MFFRC22 but the other issue still perisist.

Code: Select all

1>------ Build started: Project: ledtest3, Configuration: Debug VisualGDB ------
1>ledtest3.cpp
1>Linking ../VisualGDB/Debug/ledtest3...
1>c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -l-Wl,--rpath=$ORIGIN
1>collect2.exe : error : ld returned 1 exit status
1>Done building project "ledtest3.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

User avatar
Paeryn
Posts: 2017
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Error visual studio Pi3

Wed Dec 13, 2017 6:12 pm

topguy wrote:
Tue Dec 12, 2017 9:25 am

Code: Select all

1>c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lMFRC522
1>c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -l-Wl,--rpath=$ORIGIN
Your GCC/Linker options has some problems. For example I believe "-l-Wl,--rpath=$ORIGIN" should contain spaces between each option like this:

Code: Select all

-l -Wl, --rpath=$ORIGIN
The thing after -l should be a library name to link which in this case is missing, there shouldn't be a space between -Wl, and --rapth=$ORIGIN as -Wl says "the string following is a comma separated list of options to pass to the linker". Though $ORIGIN should have been expanded into a directory name rather than passed as a string. Something is wrong somewhere in the setup for VisualStudio, can't help with that as I don't (won't) use VS.
She who travels light — forgot something.

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 5 guests