Unable to link the 64bit ftd2xx static library with project dispaying linker error. How to link the ftd2xx 64bit library to the code - codeblocks

I'm trying to link the ftd2xx.lib (amd64 https://www.ftdichip.com/Drivers/CDM/CDM%20v2.12.28%20WHQL%20Certified.zip) static file to my test program in codeblocks. I'm running codeblocks(mingw) on a intel i3-7020, x64 based processor. I'm getting the linker error obj\Debug\main.o:main.cpp|| undefined reference to `_imp__FT_ListDevices#12'. Can someone please tell me how to link the static library of ftd2xx.lib 64bit version in codeblocks.
#include <iostream>
#include "ftd2xx.h"
using namespace std;
int main()
{
FT_STATUS ftStatus;
int numDevs;
ftStatus = FT_ListDevices(&numDevs,NULL,FT_LIST_NUMBER_ONLY);
cout<<numDevs<<endl;
return 0;
}
It is supposed to compile successfully and display the number of devices connected.

Related

g++ libstdc++-v3 ‘thread’ is not a member of ‘std’

I am building gcc 9.10 and it works great with c threads but im doing something wrong with g++ and libstdc++-v3 I just dont know what.
I compile gcc/g++, glibc, and libstdc++-v3
I see that the file at include/c++/9.1.0/threads
When I go to compile a simple test program I get
error: ‘thread’ is not a member of ‘std’
C pthread test program compiles
#include <pthread.h>
int main(){
tpthread_t t;
}
C test program compiles
#include <threads.h>
int main(){
thrd_t t;
}
Cxx test program does not compile
#include <thread>
int main(){
std::thread t;
}
Gets error
error: ‘thread’ is not a member of ‘std’
Looking into the header include/c++/9.1.0/threads
#if defined(_GLIBCXX_HAS_GTHREADS)
it looks like it skips everything if that is not defined
how can I check to see if thats the case and then why?
I made this little test and it compiles indicating to me that _GLIBCXX_HAS_GTHREADS is not defined
int main(){
#if defined(_GLIBCXX_HAS_GTHREADS)
123 here error
#endif
}
when compiling libstdc++-v3 I use
../libstdc++-v3/configure -v --enable-libstdcxx-threads=yes
even though I would think threads should be enabled by default on a linux x64 system
The other question doesnt help my situation it was from a long time ago and gcc has changed. One comment looks like it touches on my issue but doesnt go any deeper
If you look in the thread header, it appears that the class only exists #if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1). I'm not sure though, what you'd have to do to have those defined
Thats the issue im having but theres no solution
The answer was to configure with --enable-threads=yes I dont know why that was so hard to find and why thats not default

AVX Command Error for integer addition [duplicate]

Im learning to use intrinsics instead of asm-inlining. Yesterday, they were working but I always get error today. Changed nothing.
#include <iostream>
#include <intrin.h> // immintrin.h, smmintrin.h ... tried all, never worked
using namespace std;
int main()
{
_m256_zeroupper(); // __mm256_zeroupper(); does not work too
_mm128 x; // __mm128 x; does not work too
_mm256 y; // __mm256 y; does not work too
_m256_zeroupper(); // __mm256_zeroupper(); does not work too
cout << "Hello world!" << endl;
return 0;
}
Here are the errors. I tried all header files for different intrinsics but errors were same. Also reinstalled gcc but did not work.
Where am I wrong? What do I need to add to actually declare these intrinsic variables and functions?
C:\indirmeDenemesi\hello_intrin\main.cpp||In function 'int main()':|
C:\indirmeDenemesi\hello_intrin\main.cpp|8|error: '_mm256_zeroupper' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|9|error: '_mm128' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|9|error: expected ';' before 'x'|
C:\indirmeDenemesi\hello_intrin\main.cpp|10|error: '_mm256' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|10|error: expected ';' before 'y'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|
Using 64-bit latest version of gcc on 64bit cpu with 64 bit windows.
CPU is FX8150.
Tried -march=bdver1 -mtune=bdver1 and it produced hundreds of junk error.
Does all these mean my CPU is dying?
Edit: some other projects are working now, but I did not change anything. This must be a project-specific thing.
Using code::blocks and when I right-click on a header and select "open", it gives error "could not find" but does not give any error when compiling related to that, just error for intrinsinc commands. Same for working projects(they compile everything and work, but does not find header files when right click and click open). Maybe some other windows services were interfering? I dont know but compiler errors are vanishing and coming again, time to time. Reinstalling also codeblocks did not solve. Only some projects can use intrinsics while other projects cannot(even if all projects have same headers.)
This code below does not work too.
#include <iostream>
#include <immintrin.h>
using namespace std;
int main()
{
_m256_zeroupper();
__mm128 x;
__mm256 y;
_m256_zeroupper();
cout << "Hello world!" << endl;
return 0;
}
Three things should make your code work:
Make sure you're using the -mavx compile flag.
Your variable should be declared as __m256 not _mm256.
Make sure you're including immintrin.h

Codeblocks: Including library

I am trying to get started with the VJoy virtual joystick, but i am having trouble getting it up and running.
I keep getting this error:
main.cpp|14| undefined reference to `_imp__vJoyEnabled'
I am trying to get it running using the code below.
#include <iostream>
#include <windows.h>
#include <stdlib.h>
#include "public.h"
#include "vjoyinterface.h"
using namespace std;
int main()
{
// Get the driver attributes (Vendor ID, Product ID, Version Number)
if (!vJoyEnabled())
{
cout << "Function vJoyEnabled Failed - make sure that vJoy is installed and enabled\n" << endl;
}
cout << "Hello world!" << endl;
return 0;
}
Within Codeblocks i have set the compiler to compile with C++11.
Also within Codeblocks i have linked the library (Project build options -> linker settings -> add library)
I have also tried playing with the Search Directory, but i can't seem to get it working.
Any ideas what i am missing?
I found out i was linking to the wrong locations. Unfortunately there wasn't a clear error indicating this.
So the solution to this problem(in my case):
-Make sure you link to the right library locations
-Move the libraries and all of its associated files inside of the codeblocks project folder
-Add the library to the linked libraries(Project build options -> Linker settings -> Link libraries)
-Add the library locations to the search directories(Project build options -> Search directories -> Linker -> add)

How to link RtlIpv4StringToAddressExW function?

I am not able to link RtlIpv4StringToAddressExW(). This is a simplified version of my program.
#include <WinSock2.h>
#pragma comment(lib, "ws2_32.lib")
#include <Windows.h>
#include <cstdio>
#include <MSTcpIP.h>
HRESULT doMAin()
{
LONG error;
PSOCKADDR_IN sin4;
error = RtlIpv4StringToAddressExW(
L"127.0.0.1",
TRUE,
&sin4->sin_addr,
&sin4->sin_port);
return S_OK;
}
And the error I am getting is:
main.obj : error LNK2001: unresolved external symbol __imp__RtlIpv4StringToAddressExW#16
Does anyone know what could be wrong?
"An import library containing the RtlIpv4StringToAddressEx function is not included in the Microsoft Windows Software Development Kit (SDK) released for Windows Vista. The RtlIpv4StringToAddressEx function is included in the Ntdll.lib import library included in the Windows Driver Kit (WDK). An application could also use the GetModuleHandle and GetProcAddress functions to retrieve the function pointer from the Ntdll.dll and call this function."
from the docs.
If there was a lib to pragma comment, it would be Ntdll.lib. To repeat the docs, you can either grab the one from the DDK, or GetProcAddress the sucker.
GetProcAddressing would look like
typedef LONG (NTAPI *pfRtlIpv4StringToAddressEx)(PCWSTR,BOOLEAN,IN_ADDR *,PUSHORT);
pfRtlIpv4StringToAddressEx pRtlIpv4StringToAddressEx = (pfRtlIpv4StringToAddressEx)GetProcAddress(GetModuleHandle("ntdll.dll"), "RtlIpv4StringToAddressExW");
error = (*pRtlIpv4StringToAddressEx)(
L"127.0.0.1",
TRUE,
&sin4->sin_addr,
&sin4->sin_port);

Creating Haskell shared libraries on OS X

I'm trying to create a shared library from Haskell source code.
I've tried following the instruction here: http://weblog.haskell.cz/pivnik/building-a-shared-library-in-haskell/ but I'm just not having any luck.
When I compile with Haskell 64-bit (ghc 7.0.4 from 2011.4.0.0) I get the following error:
ld: pointer in read-only segment not allowed in slidable image, used in
___gmpn_modexact_1c_odd
As an alternative I also tried the 32-bit version, and depending on the exact flags I use to link get errors such as:
Library not loaded: /usr/local/lib/ghc-7.0.4/base-4.3.1.0/libHSbase-4.3.1.0-ghc7.0.4.dylib
I did manage to get a little further by adding -lHSrts to the linker line. This got me to the point of successfully linking and loading the library, but I'm then unable to find the function name using dlsym (or manually using nm | grep)
Any hints would be greatly appreciated, an example make file, or build line that has successfully built (and used) a shared library on OS X would be appreciated. I'm quite new to Haskell and don't know if I should keep banging my head assuming that the problem is on my end, or for various reasons I shouldn't expect this to work on OS X.
A git repo with all the combinations I've tried is available here: https://github.com/bennoleslie/haskell-shared-example I did manage to get something working for 32-bit ghc, but not 64-bit yet.
It is possible to create working shared libraries on 64-bit OS X, with the latest Haskell Platform release (2012.4 64bit)
The invocation line works for me:
ghc -O2 --make \
-no-hs-main -optl '-shared' -optc '-DMODULE=Test' \
-o libTest.so Test.hs module_init.c
module_init.c should be something like:
#define CAT(a,b) XCAT(a,b)
#define XCAT(a,b) a ## b
#define STR(a) XSTR(a)
#define XSTR(a) #a
#include <HsFFI.h>
extern void CAT(__stginit_, MODULE)(void);
static void library_init(void) __attribute__((constructor));
static void library_init(void)
{
/* This seems to be a no-op, but it makes the GHCRTS envvar work. */
static char *argv[] = { STR(MODULE) ".so", 0 }, **argv_ = argv;
static int argc = 1;
hs_init(&argc, &argv_);
hs_add_root(CAT(__stginit_, MODULE));
}
static void library_exit(void) __attribute__((destructor));
static void library_exit(void)
{
hs_exit();
}
This git repo: https://github.com/bennoleslie/haskell-shared-example contains a working example.
All credit goes to this original source: http://weblog.haskell.cz/pivnik/building-a-shared-library-in-haskell/
You might want to try the ghc port in Homebrew -- https://github.com/mxcl/homebrew/blob/master/Library/Formula/ghc.rb

Resources