I have started using gsl recenltly in a huge old C project. I have managed to add the libraries by adding the location in my system in Properties>C/C++>General>Additional Include Directories.
In my code, I am also including the following:
#include "gsl/gsl_matrix.h"
#include "gsl/gsl_matrix_complex_double.h"
#include "gsl/gsl_matrix_complex_float.h"
#include "gsl/gsl_matrix_complex_long_double.h"
#include "gsl/gsl_math.h"
#include "gsl/gsl_spmatrix.h"
#include "gsl/gsl_complex.h"
#include "gsl/gsl_complex_math.h"
#include "gsl/gsl_inline.h"
#include "gsl/gsl_complex.h"
I can now use most functions of gsl. but in the fowllowing function:
void vector_complex_mul_elements(gsl_vector_complex *v1, gsl_vector_complex *v2)
{
gsl_complex cpx1, cpx2, cpx3;
GSL_SET_COMPLEX(&cpx1, 0, 0);
GSL_SET_COMPLEX(&cpx2, 0, 0);
GSL_SET_COMPLEX(&cpx3, 0, 0);
if(v1->size != v2->size)
{
printf("Error: Lenght of arrays do not match.\n");
return;
}
for(i=0; i < v1->size; i++)
{
cpx1 = gsl_vector_complex_get(v1, i);
cpx2 = gsl_vector_complex_get(v2, i);
//cpx3 = gsl_complex_mul(cpx1 , cpx2);
gsl_vector_complex_set(v1, i, cpx3);
}
}
When I uncomment the line:
cpx3 = gsl_complex_mul(cpx1 , cpx2);
I get the following errors:
Error LNK2001: Unresolved external symbol "_log1p".
Error LNK2001: Unresolved external symbol "_log1p".
Error LNK2001: Unresolved external symbol "_hypot".
Error LNK1120: 2 unresolved external references.
I have already tried writing it like:
gsl_vector_complex_set(v1, i, gsl_complex_mul(cpx1 , cpx2));
Then I get these errors:
Error LNK2019: Reference to unresolved external symbol "_log1p" in function "_gsl_complex_logabs".
Error LNK2019: Reference to unresolved external symbol "_hypot" in function "_gsl_complex_div".
Error LNK2001: Unresolved external symbol "_log1p".
Error LNK1120: 2 unresolved external references.
Is this a only a linking problem or the way I am using it is wrong?
These (lop1p and hypot) functions are in the standard maths library. Are you including math.h and linking to it (-lm)? As per the GSL documentation.
It seems to me that you are wrong linked GSL library.
Try to rebuild GSL as a dll and relink it, as I showed you in your other post.
Related
foo.exe depends on bar.lib
source.c in bar.lib:
#include <time.h>
void func()
{
time_t now = time(NULL);
... // use 'now'
}
Bar.lib can be generated. However, foo.exe's linking process will report an error:
LINK2019
unresolved external symbol '_time64' referenced in function 'time'.
foo
bar.lib(source.obj)
What may cause this?
Part of my school project I need to work with LabWindows/CVI.
I need to read a xlsx file and analize it.
I download this libxl library.
I amported the h files and the lib files.
this is my code ( I coppied it from here):
#include <cvirte.h>
#include <userint.h>
#include <formatio.h>
#include "Final work.h"
#include "libxl.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int panelHandle;
int readFile()
{
BookHandle book = xlCreateBook(); // xlCreateXMLBook()
if (xlBookLoad(book, "G:/Electro data/0.5_time_all.xlsx")){
return 0;
}
if(book)
{
SheetHandle sheet = xlBookAddSheet(book, L"Sheet1", 0);
if(sheet)
{
xlSheetWriteStr(sheet, 2, 1, L"Hello, World !", NULL);
xlSheetWriteNum(sheet, 3, 1, 1000, NULL);
}
xlBookSave(book, L"example.xls");
xlBookRelease(book);
}
return 0;
}
and I am getting this errors:
Build Status (Final work.prj - Debug)
Final work.c - 3 warnings
error: Undefined symbol '_xlBookAddSheetA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlBookLoadA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlBookReleaseA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlBookSaveA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlCreateBookCA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlSheetWriteNumA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
error: Undefined symbol '_xlSheetWriteStrA' referenced in "c:\Users\USER\Documents\National Instruments\CVI\cvibuild.Final work\Debug\Final work.obj".
Build failed.
here is an image to illustrate:
What am I doing wrong?
You need to link with the provided library. From the screenshot you seem to have added the library to your project, however the linker does not get it.
I'm trying to configure VS correctly to write some simple c programs.
If a function dummy() is not found, the function name is not highlight in the code, there is only a build error:
LNK2019 unresolved external symbol dummy referenced in function main
Line: 1
Is there a way to make VS intellisense work for function names with .c files?
Why compiler doesn't show the error line number (Line: 1 is not very helpful)?
Sample:
#include <stdio.h>
#include <stdlib.h>
void dummy()
{
}
int main()
{
dummyX(); //dummyX, dummy typo. Results in "unresolved external..." error
return EXIT_SUCCESS;
}
I'm trying to write a C script able to open .mat files. The .mat files were written in Matlab 2015b 64-bit version. I'm using Visual Studio 2010 to compile the code. Here it is:
#include <stdio.h> /*Std library*/
#include "..\matlablib\mat.h" /*provided by MathWorks*/
int main(){
MATFile * pMF;
printf("Abrindo arquivo .mat...\n"); /*check (1)*/
pMF = matOpen("teste.mat","r");
printf("Arquivo .mat aberto.\n"); /*check (2)*/
getch();
}
As I compile this, I get the following message error:
matread.obj : error LNK2019: unresolved external symbol _matOpen
referenced in function _main
matread.exe : fatal error LNK1120: 1 unresolved externals
Have anyone had a similar problem before?
Thanks in advance,
Porto
I have no idea what the problem is. I am trying to build my project for release but the linker complains about not finding external symbols.
The thing that's odd is that I copy & pasted all include paths and dependencies from the Debug into the Release build configuration and double checked it.
get_PC_definition() is e.g. declared in cpudefs.h:
/* Return register definition of instruction pointer */
extern RegisterDefinition * get_PC_definition(Context * ctx);
There are a few implementations of this function - which one I chose is controled by macros so yes, I defined all necessary macros too:
RegisterDefinition * get_PC_definition(Context * ctx) {
static RegisterDefinition * reg_def = NULL;
if (!context_has_state(ctx))
return NULL;
// and so on ..
return reg_def;
}
cpudefs.obj gets build so far but the Linker just mocks around .. maybe I am already blind to the error but like I said, I copied the configurations from the Debug into the Release build configuration.
Any ideas what I could try?
Error output:
Error 43 error LNK1120: 9 unresolved externals C:\svn\AgentSib\Release\agentsib.exe agentsib
Error 31 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\registers.obj agentsib
Error 32 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\runctrl.obj agentsib
Error 34 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\symbols_cdb.obj agentsib
Error 35 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\cpudefs.obj agentsib
Error 36 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\expressions.obj agentsib
Error 37 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\funccall.obj agentsib
Error 38 error LNK2001: unresolved external symbol _get_PC_definition C:\svn\AgentSib\AgentSib\profiler_sst.obj agentsib
Error 41 error LNK2019: unresolved external symbol _BREAK_INST referenced in function _get_break_instruction C:\svn\AgentSib\AgentSib\cpudefs.obj agentsib
Error 27 error LNK2019: unresolved external symbol _cpu_bp_get_capabilities referenced in function _context_get_supported_bp_access_types C:\svn\AgentSib\AgentSib\context-sib.obj agentsib
Error 30 error LNK2019: unresolved external symbol _cpu_bp_on_resume referenced in function _sib_resume C:\svn\AgentSib\AgentSib\context-sib.obj agentsib
Error 28 error LNK2019: unresolved external symbol _cpu_bp_plant referenced in function _context_plant_breakpoint C:\svn\AgentSib\AgentSib\context-sib.obj agentsib
Error 29 error LNK2019: unresolved external symbol _cpu_bp_remove referenced in function _context_unplant_breakpoint C:\svn\AgentSib\AgentSib\context-sib.obj agentsib
Error 42 error LNK2019: unresolved external symbol _crawl_stack_frame referenced in function _trace_stack C:\svn\AgentSib\AgentSib\stacktrace.obj agentsib
Error 33 error LNK2019: unresolved external symbol _get_PC_definition referenced in function _command_get_children_cache_client C:\svn\AgentSib\AgentSib\stacktrace.obj agentsib
Error 39 error LNK2019: unresolved external symbol _ini_cpudefs_mdep referenced in function _ini_cpudefs C:\svn\AgentSib\AgentSib\cpudefs.obj agentsib
Error 40 error LNK2019: unresolved external symbol _regs_index referenced in function _get_reg_by_dwarf_id C:\svn\AgentSib\AgentSib\cpudefs.obj agentsib
Edit:
Calling function get_PC_definition()
static int set_debug_regs(Context * ctx, int check_ip, int * step_over_hw_bp) {
int i;
int ret;
uint32_t dr7 = 0;
ContextAddress ip = 0;
ContextExtensioni8051 * dext = EXT(ctx);
ContextExtensioni8051 * bps = EXT(context_get_group(ctx, CONTEXT_GROUP_BREAKPOINT));
RegisterDefinition *reg_def = NULL;
ret = 0;
if (check_ip) {
*step_over_hw_bp = 0;
reg_def = get_PC_definition(ctx);
ret = context_read_reg(ctx, reg_def, 0, reg_def->size, &ip);
if ( ret < 0 )
return -1;
}
return 0;
}
This question "Visual Studio 2010's strange "warning LNK4042"" had the solution to my problem.
After all it was a linker problem caused by the compiler..
Under Configuratoin Properties >> C/C++ >> Output Files >> Object File Name I used for both configurations $(IntDir) whereas it worked for Debug but not for Release. Does anybody know why?
Changing it to
$(IntDir)\%(RelativeDir)
was the solution that saved my day.